I am trying to open facebook page when user click on imageview..but if app is installed then it works fine,but what i want is if app is not installed then it should open in browswer,,following is my code..
iv_fb.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
boolean installed = appInstalledOrNot("fb://page/pageid");
if(installed) {
//This intent will help you to launch if the package is already installed
/* Intent LaunchIntent = getPackageManager()
.getLaunchIntentForPackage("com.facebook.katana");*/
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/pageid")));
ContactActivity.this.finish();
// startActivity(LaunchIntent);
System.out.println("App is already installed on your phone");
} else {
System.out.println("App is not currently installed on your phone");
}
// TODO Auto-generated method stub
}
});
private boolean appInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
boolean app_installed;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
}
catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}
Aucun commentaire:
Enregistrer un commentaire