My app requires to check if an email app is present so we can hide a button for sending the email.
On API 30, Android has made change to the package manager so we cannot access the activities anymore, unless they have been declared in the <queries> tag.
I have setup the queries node on the AndroidManifest file as follows
<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.APP_EMAIL" />
</intent>
</queries>
When I try to query using the the intent, the method on the package manager returns zero items.
fun isEmailAppInstalled(context: Context): Boolean {
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_APP_EMAIL)
return context.packageManager.queryIntentActivities(intent, 0).isNotEmpty()
}
