无法从隐式意图启动 kakao 谈话

Unable to launch kakao talk from implicit intent

我愿意使用隐式意图打开 KakaoTalk。以下是我的代码。

PackageManager pm = getActivity().getPackageManager();
        try {

            Intent waIntent = new Intent(Intent.ACTION_SEND);
            waIntent.setType("text/plain");
            String text = "";

            PackageInfo info = pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
            waIntent.setPackage("com.kakaotalk");

            waIntent.putExtra(Intent.EXTRA_TEXT, text);
            startActivity(Intent.createChooser(waIntent, "Share with"));

        } catch (PackageManager.NameNotFoundException e) {
            Toast.makeText(getActivity(),"kakao talk not Installed", Toast.LENGTH_SHORT).show();
        }

虽然我的手机安装了kakao talk,但它说没有安装kakao talk。我该如何解决这个问题?

您正在捕捉 PackageManager.NameNotFoundException。这可能是由 pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA); 抛出的。在那里,您要求 com.whatsapp。据推测,这不是您要查找的应用程序的应用程序 ID。