@SuppressWarnings("unused")
private boolean isFacebookExists() {
try{
ApplicationInfo info =
getPackageManager().getApplicationInfo("com.facebook.katana", 0 );
return true;
} catch(
PackageManager.NameNotFoundException e ){
return false;
}
}
== Once you know that Facebook exists in your device then launch it by following
String uri = "facebook://facebook.com/inbox";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
In the other way you an directly take the intent if you must call the Facebook even if the app doesn't exists.
@SuppressWarnings("unused")
private Intent
isFacebookExists() {
Intent intent;
String uri;
try{
ApplicationInfo info =
getPackageManager().getApplicationInfo("com.facebook.katana", 0 );
uri = "facebook://facebook.com/inbox";
} catch( PackageManager.NameNotFoundException e ){
uri = "http://www.facebook.com";
}
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
return intent;
}
Cheers !!!
No comments:
Post a Comment