- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
大家好,我在 youtube 上发现了有趣的 Facebook 实现方法,虽然有些方法已被弃用,但我发现它很容易使用,因为我是我的 Android 应用程序中 Facebook 实现的新手。我遇到了一些问题,我通过登录 Activity 成功登录到 Facebook,但在那里他们在同一 Activity 中显示用户个人资料,在我的情况下,我不想在我保存用户的另一个 Activity 中显示他们共享首选项中的凭据和 session 有效但是在实现用户配置文件的解析内容时我什么也没得到不知道为什么这是我的代码。
在此输入验证码
private void updateView()
{
// TODO Auto-generated method stub
if(fb.isSessionValid())
{
Intent openActivity=new Intent(FacebookLoginActivity.this,AccountInfoActivity.class);
startActivity(openActivity);
}
}
这里的 session 有效,所以我可以进行下一个 Activity
在此输入验证码
public class AccountInfoActivity extends Activity
{
Facebook fb;
String id,name,email;
Bitmap bmp;
ImageView profile_pic;
TextView facebook_name,facebook_email;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_profile);
String APP_ID= "**************";
fb= new Facebook(APP_ID);
profile_pic=(ImageView)findViewById(R.id.profile_pic);
facebook_name=(TextView)findViewById(R.id.facebookName);
facebook_email=(TextView)findViewById(R.id.facebookEmail);
(new DataProgressTask()).execute();
}
public class DataProgressTask extends AsyncTask<String, Void, Boolean>
{
ProgressDialog progress;
public DataProgressTask()
{
progress = new ProgressDialog(AccountInfoActivity.this);
}
protected void onPreExecute()
{
progress.setMessage("Loading data ...");
progress.show();
}
@Override
protected void onCancelled()
{
if ( progress != null )
{
progress.dismiss();
}
}
protected void onPostExecute(final Boolean success)
{
//Check if dialog still runing dismiss
if ( progress != null)
{
progress.dismiss();
}
if (success)
{
facebook_name.setText(name);
facebook_email.setText(email);
profile_pic.setImageBitmap(bmp);
}
else
{
Toast.makeText(getBaseContext(), "Check your Internet Connection", Toast.LENGTH_SHORT).show();
}
}
@SuppressWarnings("deprecation")
protected Boolean doInBackground(final String... args)
{
if(fb.isSessionValid())
{
JSONObject obj= null;
URL img_url = null;
String jsonUser;
try
{
jsonUser = fb.request("me");
obj = Util.parseJson(jsonUser);
id = obj.optString("id");
name= obj.optString("name");
email= obj.optString("email");
//getting the image of the user
img_url = new URL("http://graph.facebook.com/"+id+"/picture?type=small");
//decode it to bitmap
bmp =BitmapFactory.decodeStream(img_url.openConnection().getInputStream());
profile_pic.setImageBitmap(bmp);
}
catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (FacebookError e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (JSONException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return true;
}
}}
如有任何帮助,我们将不胜感激。谢谢
最佳答案
我设法通过将用户配置文件的数据从登录 Activity 发送到其他 Activity 来解决我的问题,如果 session 有效,则所有这些都已完成:D
关于android - 登录后在另一个 Activity 中获取 Facebook 个人资料,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24875781/
我正在使用passport.js 为我的node.js 应用程序提供OAuth 身份验证。但我确实有一个疑问: 当我在身份验证时收到配置文件对象(当您定义 OAuth 策略时)时,该对象对于所有提供商
我正在尝试对 wordpress 布局进行解码/逆向工程。我正在浏览 CSS 文件,无法弄清楚这个长长的菜单 mumbo-jumbo 是什么! 我不是要任何人检查代码,而是让我知道我在看什么。这些似乎
所以我尝试制作一个包含私有(private)配置文件的 symfony 项目,并且我使用 FriendsOfSymfony,但是如果我创建两个用户,每个人都可以看到其他人上传的文件。我尝试在多个网站上
我正在编写一个需要使用已登录 G+ 用户的公开个人资料图片的 JS 应用。 如果我有用户 ID,我可以使用 Google+ API 查询个人资料数据。 https://developers.googl
我看过很多关于 facebook 身份验证的帖子,要么是旧的,要么不能正常工作。 然而,最终我在我的项目中做了一些可行但不完全的东西。这是我要求的代码 var facebookAuth
我是一名优秀的程序员,十分优秀!