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.
Title: Check and request to install Facebook App
Rating: 100% based on 99998 ratings. 10 user reviews.
Post by 12:18 PM
Rating: 100% based on 99998 ratings. 10 user reviews.
Post by 12:18 PM
0 comments:
Post a Comment