[Solved] Fix the Intent issue in Android 11(R)- API 30 or higher

A few months back, I have created a basic android application for my personal use that was later shared around my circle.

One of the users WhatsApp me and said, “Hey Gagan, you’re application” Send WhatsApp Message” is not working anymore.” please look into this; I need it for my work.

I said, “can you tell me what is the problem? honestly I’m not using that application anymore, so I don’t know what wrong happened to the application”.

He immediately replied, When I click on “send message,” It won’t ask for WhatsApp or not showing a list of applications.

Alright, Let me get my application code, and I’ll back to you shortly with the working app.

Intent not working in Android 11 or higher

After sitting for hours, I finally fixed the application and will share the method for the same. As you know, Android 11 is primarily focused on security context.

Because of that, you can say they have added a separate permission layer for more secure intent action to avoid unwanted security compromises.

In the earlier version of android, intent action will list out all the available apps for specific tasks without making any changes, but from now onwards, you need to mention the package name in AndroidManifest.xml.

And this method is called Package visibility filtering.

In the next half, we will see how to implement it on your Android project.

Intent working method in Android 11 or higher

To fix this issue we have couple of way to follows <queries> </queries> or <uses-permission> </uses-permission>.

  • <queries></queries>:- The preferable way to list out available applications is to open AndroidManifest.xml and add the highlighted line with a list of package names that you want to display.
  • Inside queries tag explicitly mention respective package to show up when intent action is required.
  • This method will show the only package which is listed in the <queries> tag.
  • After that, run the application to see changes.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
**********
**********
<!-- Specific apps you interact with, eg: -->
<queries>
    <package android:name="com.whatsapp" />
</queries>
**********
**********
<application
        android:allowBackup="true"
  • <uses-permission></uses-permission> :- This parameter will list out all the available application for supportable task.
  • It is similar to an older version of Android.
  • I better advise you to go with a <queries> tag for more secure behavior.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
**********
**********
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" />
**********
**********
<application
        android:allowBackup="true"

Read this:- How to Fix Exception ‘open failed: EACCES (Permission denied)’ on Android

Wrapping-up

That’s all to Fix the Intent issue in Android 11(R)- API 30 or higher version.

When you use the <queries> tag, use the try-and-catch method for a more robust and crash-proof application.

I hope so you’re problem has been resolved. If the problem persists, feel free to contact us.

If you want to share or missed something that would help others, please share in a comment section.

This Post Has 5 Comments

  1. Ridhima

    Your style is so unique compared to many other people. Thank you for publishing when you have the opportunity, Guess I will just make this bookmarked.

    1. Gagan Mishra

      Thanks for your kind word!

  2. Atajan

    Hi Gagan, please help me im already ready to publish my app but this problem with Intent in API 30 hold me and i can’t fix, i don’t know what to do hope you are help me soon

    1. Haris Rahman

      please send me the code

Leave a Reply