I want to check whether an app is installed on the device or not. I am using code below :
PackageManager pm = context.getPackageManager();
List
like whatsapp
shareImage("com.whatsapp", "Whatsapp");
call
public void shareImage(String pkgname, String appname) {
String path = null;
try {
path = MediaStore.Images.Media.insertImage(getContentResolver(),
arrImagePath.get(slidePager.getCurrentItem()), "Title", null);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
Uri uri = Uri.parse(path);
Intent share = new Intent(Intent.ACTION_SEND);
share.setPackage(pkgname);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setType("image/*");
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(share, "Share image File");
}