有意打开whatsapp在android os 11中不起作用,但在android(os)10设备上工作正常,它会在android 11设备上显示消息“whatsapp app not installed in your phone”。有人有解决办法吗?
String contact = "+91 9999999999"; // use country code with your phone number
String url = "https://api.whatsapp.com/send?phone=" + contact;
try {
PackageManager pm = context.getPackageManager();
pm.getPackageInfo("com.whatsapp", PackageManager.GET_ACTIVITIES);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
context.startActivity(i);
} catch (PackageManager.NameNotFoundException e) {
Toast.makeText(mContext, "Whatsapp app not installed in your phone",Toast.LENGTH_LONG).show();
e.printStackTrace();
}
1条答案
按热度按时间j8yoct9x1#
android 11在软件包可见性方面有新的变化。
您需要向应用程序清单中添加一个新分区:
您可以在文档中找到更多信息:https://developer.android.com/training/basics/intents/package-visibility