I was trying to check whether facebook app is installed on a device or not.
while searching i found this link How to check if Facebook is installed Android
based on the above link my method is as below
PackageManager pm = getPackageManager();
PackageInfo pinfo=null;
try {
pinfo=pm.getPackageInfo("com.facebook.katana",
PackageManager.GET_ACTIVITIES);
return ((pinfo!=null)?true:false);
} catch (PackageManager.NameNotFoundException e) {
return false;
}
i checked the device facebook is not in installed app list,but the flag is always true and even package manager didn`t throw the NameNotFoundException.
when i try to launch fb activity like this nothing happens
File file = new File(imagePath);
final Intent fbIntent = new Intent(Intent.ACTION_SEND);
fbIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri fileUri = FileProvider.getUriForFile(this, "com.test.provider", file);
fbIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
fbIntent.putExtra(Intent.EXTRA_TEXT,"gudmorning");
fbIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
fbIntent.setType("image/*");
fbIntent.setPackage("com.facebook.katana");
startActivity(fbIntent);
I also checked the code for package name "com.facebook.orca" also which is package name for messenger app.
what could be the possible reason or any other method to perform this check.