我有一点问题,我有这个代码,到目前为止它打开我想要的所有共享首选项,当我选择whatsapp或任何其他媒体分享它说dosto支持该文件,发生了什么?感谢
public void onClickWhatsApp(View view) {
PackageManager pm = getPackageManager();
try {
Uri imageUri = Uri.parse("android.resource://" + getPackageName()
+ "/drawable/" + "ic_launcher");
PackageInfo info = pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "text example");
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "send"));
} catch (PackageManager.NameNotFoundException e) {
Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
.show();
}
}