Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of installed apps in Android 11

This line is described on the developer site but I did not understand it perfectly

Call getInstalledApplications() or getInstalledPackages(). Both methods should return a filtered list.

Actually, I need to test Testing package visibility behavior

https://developer.android.com/training/package-visibility/testing

like image 508
ajay bisaveni Avatar asked Apr 21 '21 05:04

ajay bisaveni


People also ask

How do I see all apps on Android 11?

Swipe up from the bottom of your screen to the top. If you get All Apps , tap it. Tap the app that you want to open.

How do I know if an app is installed on Android 11?

getPackageInfo(packageName, 0); return true; } catch (PackageManager. NameNotFoundException e) { return false; } } // ... // This will return true on Android 11 if the app is installed, // since we declared it above in the manifest. isPackageInstalled("com. example.

Where are system apps stored Android 11?

/​system/​app/​ - Contains pre-installed system apps. /​data/​asec/​ - Stores secure apps generated from external memory storage. /​data/​app-private - Contains third party protected apps.

How do I get a list of apps on my phone?

On your Android phone, open the Google Play store app and tap the menu button (three lines). In the menu, tap My apps & games to see a list of apps currently installed on your device. Tap All to see a list of all apps you've downloaded on any device using your Google account.


1 Answers

There are 3 different ways of querying installed apps of the user in Android 11.

  1. If you already know which apps you want to query just mention the package names inside the <queries> element in the AndroidManifest.
<manifest package="com.nikit.app">
    <queries>
        <package android:name="com.fake.app" />
        <package android:name="com.fake.game" />
    </queries>
    ...
</manifest>
  1. In case you don’t know all the package names of the apps that you want to query but there is a set of apps with similar functionality that you want to query then you can use an intent filter inside the <queries> element according to your requirements like it has been done in the code snippet below.
<manifest package="com.nikit.app">
    <queries>
        <intent>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="image/jpeg" />
        </intent>
    </queries>
    ...
</manifest>

The <intent> element looks like <intent-filter> but there are few differences. element has the following restrictions:

  • The <intent> element can have only one <action> element.
  • The element can only have the following attributes : mimeType, scheme and host.
  1. If you want to query all the apps of the user like you were doing earlier, you need to include QUERY_ALL_PACKAGES permission in the AndroidManifest. It is a normal permission and it is granted as soon as the app is installed.
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
like image 172
shirley Avatar answered Sep 29 '22 04:09

shirley