【发布时间】:2021-02-28 11:39:18
【问题描述】:
有意打开 Whatsapp 在 android OS 11 中不起作用,但在 android (OS) 10 设备上运行良好,它会在 android 11 设备上显示消息“Whatsapp 应用程序未安装在您的手机中”。有人对此有解决方案吗?
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();
}
【问题讨论】:
-
嘿,你是说 OS11 还是 Android 11?你的意思可能是模棱两可的。考虑编辑您的问题。
标签: java android android-studio android-intent whatsapp