android – how can i share link only to facebook's app (lite,original, messenger,messenger lite)?-ThrowExceptions

Exception or error:

I want to share the link only to facebook’s app (lite,original, messenger,messenger lite)
I tried the below code but not working.
I also tried other stack solutions but not working pls help me out.

List<ResolveInfo> matches = appCompatActivity.getPackageManager().queryIntentActivities(shareIntent, PackageManager.MATCH_DEFAULT_ONLY);
            for (ResolveInfo info: matches) {
                if (info.activityInfo.packageName.toLowerCase().startsWith("com.facebook.katana") ||
                        info.activityInfo.packageName.toLowerCase().startsWith("com.facebook.lite")) {
                    intent.setPackage(info.activityInfo.packageName);

                    break;
                }
            }
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *