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.
<!-- Specific apps you interact with, eg: -->
<package android:name="com.whatsapp" />
- <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.
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" />
Read this:- How to Fix Exception ‘open failed: EACCES (Permission denied)’ on Android
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.
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.