我正在开发材质设计应用程序。
当用户单击应用程序中的“在Facebook上喜欢”文本(布局)时,我想打开应用程序的Facebook页面。
我已经成功打开了Facebook应用程序,但是我无法弄清楚如何直接打开我的页面!
到目前为止,这是我所做的:
LinearLayout linearLayoutFacebookContainer = (LinearLayout) findViewById(R.id.facebook_container);
linearLayoutFacebookContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Handler handler3 = new Handler();
handler3.postDelayed(new Runnable() {
@Override
public void run() {
Intent facebookIntent = getPackageManager().getLaunchIntentForPackage("com.facebook.katana");
if (facebookIntent != null) {
// We found the activity now start the activity
facebookIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
facebookIntent.setData(Uri.parse("https://www.facebook.com/HumaneHelper/"));
startActivity(facebookIntent);
} else {
// Bring user to the market or let them choose an app?
facebookIntent = new Intent(Intent.ACTION_VIEW);
facebookIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
facebookIntent.setData(Uri.parse("https://www.facebook.com/HumaneHelper/"));
startActivity(facebookIntent);
}
}
}, 200);
}
});
请告诉我。
我是初学者,请配合。
提前致谢。
fb:// page / {id}是一种解决方法:
final String url = "fb://page/" + facebookID
Intent facebookAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
facebookAppIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(facebookAppIntent);
您确定使用的是Facebook页面的ID号而不是用户名吗?
我的意思是,例如,如果您想打开Facebook本身的Facebook页面(即https://www.facebook.com/facebook),则必须使用:
fb://page/20531316728
由于20531316728是Facebook页面的ID(而facebook是username)。
如果您不知道Facebook页面的ID,则可以打开以下页面进行检索:
https://graph.facebook.com/{username}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句