简体   繁体   English

获取android 11(API 30)中所有已安装的应用程序,如何获取android 11中安装的所有其他应用程序?

[英]Get all installed apps in android 11 (API 30) , how to get all other apps installed in android 11?

How can we get all installed applications in android 11?怎样才能得到android 11中所有已安装的应用程序呢? for Android 10 it is working fine but when I updated to android 11 then all of them are gone.对于 Android 10 它工作正常但是当我更新到 android 11 然后所有这些都消失了。

From Android 11 Google has introduced a new permission to query all installed apps on android devices.来自 Android 11 谷歌推出了一项新权限,可以查询 android 设备上所有已安装的应用程序。 So if you want to get all applications in yours app for some reason then just add following permission in your manifest因此,如果您出于某种原因想要在您的应用程序中获取所有应用程序,那么只需在您的清单中添加以下权限

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>

or for specific category of apps you can use this in your manifest.或者对于特定类别的应用程序,您可以在清单中使用它。 for example if you want only apps with android.intent.category.HOME category then add this code.例如,如果您只想要android.intent.category.HOME类别的应用程序,则添加此代码。

<queries>
   <intent>
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.HOME" />
    </intent>
</queries> 

also you can filter apps more specifically by adding more categories to it like shown below您还可以通过向其添加更多类别来更具体地过滤应用程序,如下所示

<queries>
   <intent>
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.HOME,android.intent.category.DEFAULT" />
  </intent>
</queries> 

Update to Above Ali's answer更新到 Above Ali 的回答

The queries tag does not work inside the application tag, so you have to add it inside the manifest tag, but outside the application tag like this queries标签在application标签内不起作用,所以你必须将它添加到manifest标签内,但在application标签之外,就像这样

<manifest
    <uses-permission
        android:name="android.permission.QUERY_ALL_PACKAGES"
        tools:ignore="QueryAllPackagesPermission" />
    <uses-permission
        android:name="android.permission.PACKAGE_USAGE_STATS"
        tools:ignore="ProtectedPermissions" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
    </application>
    <queries>
        <intent>
            <action android:name="android.intent.action.MAIN" />
        </intent>
    </queries>
</manifest>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM