小编Joh*_*ohn的帖子

通过意图打开 whatsapp 在 Android 11 中不起作用

有意打开 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();
        }
Run Code Online (Sandbox Code Playgroud)

java android android-intent whatsapp android-studio

6
推荐指数
3
解决办法
2960
查看次数

标签 统计

android ×1

android-intent ×1

android-studio ×1

java ×1

whatsapp ×1