簡體   English   中英

返回沒有系統應用程序的一組已安裝應用程序

[英]Returning a set of installed applications without system apps

我想知道我需要編寫什么代碼才能返回一組非系統應用程序。

    public static List<?> getInstalledApplication(Context c) {
    return c.getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);

}

這是返回所有內容的方法的代碼。 我只想顯示具有用戶啟動功能的應用程序。 我怎樣才能做到這一點?

查看有關@Wand Maker的評論,以解決以下問題: 如何在Android中安裝已安裝的應用程序,而沒有系統應用程序?

我認為您需要使用PackageManager找出所有支持意圖過濾器的應用程序,這些應用程序具有動作“ android.intent.action.MAIN”和類別“ android.intent.category.LAUNCHER” – Wand Maker 7月6日15:23

您可以使用PackageManager.queryIntentActivities( http://developer.android.com/reference/android/content/pm/PackageManager.html#queryIntentActivities ( android.content.Intent ,int))來完成此操作

例如

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM