Modify btnStartFacebookOnClickListener from the last exercise:
OnClickListener btnStartFacebookOnClickListener
= new OnClickListener(){
@Override
public void onClick(View v) {
String facebookPackageName = "com.facebook.katana";
String facebookClassName = "com.facebook.katana.LoginActivity";
try {
ApplicationInfo facebookAppInfo = getPackageManager()
.getApplicationInfo(facebookPackageName, 0);
Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName(facebookPackageName, facebookClassName);
startActivity(intent);
} catch (NameNotFoundException e) {
// Didn't installed
Toast.makeText(getApplicationContext(), "Facebook not found! INSTALL.", Toast.LENGTH_LONG).show();
//Start Market to downoad and install Facebook App
Uri uri = Uri.parse("market://details?id=" + facebookPackageName);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
}};
Next:
- Launch Facebook app from a specified page, using intent with ACTION_VIEW.
No comments:
Post a Comment