當前位置: 首頁>>代碼示例>>Java>>正文


Java PackageManager.getInstalledApplications方法代碼示例

本文整理匯總了Java中android.content.pm.PackageManager.getInstalledApplications方法的典型用法代碼示例。如果您正苦於以下問題:Java PackageManager.getInstalledApplications方法的具體用法?Java PackageManager.getInstalledApplications怎麽用?Java PackageManager.getInstalledApplications使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.getInstalledApplications方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getInstalledPackages

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public static List<ResolveInfo> getInstalledPackages(PackageManager pm, Context context) {
    DebugLog log = DebugLog.get(context);
    if (log.isEnabled()) {
        log.writeLog("Getting installed packages. Will try a few different methods to see if I receive a suitable app list.");
    }

    Intent startupIntent = new Intent(Intent.ACTION_MAIN);
    startupIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    List<ResolveInfo> resolveInfos = pm.queryIntentActivities(startupIntent, 0);

    if (log.isEnabled()) {
        log.writeLog("Got " + resolveInfos.size() + " apps via queryIntentActivities.");
    }

    List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_META_DATA);
    if (log.isEnabled()) {
        log.writeLog("Got " + appInfos.size() + " apps via getInstalledApplications with GET_META_DATA.");
    }

    appInfos = pm.getInstalledApplications(0);
    if (log.isEnabled()) {
        log.writeLog("Got " + appInfos.size() + " apps via getInstalledApplications with no flags");
    }

    return resolveInfos;
}
 
開發者ID:abhijitvalluri,項目名稱:fitnotifications,代碼行數:27,代碼來源:Func.java

示例2: doInBackground

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@Override
   protected String doInBackground(String... params) {     
	final PackageManager packageManager = getApplicationContext().getPackageManager();
	List<ApplicationInfo> installedApplications = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);	
	for (ApplicationInfo appInfo : installedApplications)
	{
		if(appInfo.packageName.equals(i))
		{
  	Intent k = new Intent();
  	PackageManager manager = getPackageManager();
  	k = manager.getLaunchIntentForPackage(i);
  	k.addCategory(Intent.CATEGORY_LAUNCHER);
  	startActivity(k);
  	
      try {
	getInputStreamFromUrl(URL + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("urlPost", "") + "UID=" + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("AndroidID", "") + "&Data=", "Opened App: " + i);
} catch (UnsupportedEncodingException e) {
	 
	e.printStackTrace();
}        	
		}
	}
 return "Executed";
   }
 
開發者ID:mwsrc,項目名稱:Dendroid-HTTP-RAT,代碼行數:25,代碼來源:MyService.java

示例3: getAppLogosArray

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public ArrayList<Drawable> getAppLogosArray() {
    PackageManager pm = context.getPackageManager();
    listOfAppInfo = pm.getInstalledApplications(pm.GET_META_DATA);

    for(ApplicationInfo app : listOfAppInfo) {

        if(pm.getLaunchIntentForPackage(app.packageName) != null) {
            // apps with launcher intent
            if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 1) {
                // updated system apps

            } else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
                // system apps

            } else {
                // user installed apps
                appLogosArray.add(app.loadIcon(pm));

            }
        }

    }
    return appLogosArray;
}
 
開發者ID:01sadra,項目名稱:Detoxiom,代碼行數:25,代碼來源:AppNameAndLogoProvider.java

示例4: getAllInstelAppUrl

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * 獲取所有app的安裝路徑
 *
 * @param context
 * @return ArrayList<HashMap<String, String>> package:包名,url:地址
 */
public static ArrayList<HashMap<String, String>> getAllInstelAppUrl(
        Context context) {

    ArrayList<HashMap<String, String>> appInfos = new ArrayList<HashMap<String, String>>();

    PackageManager pm = context.getPackageManager();

    for (ApplicationInfo app : pm.getInstalledApplications(0)) {

        HashMap<String, String> appInfo = new HashMap<String, String>();
        appInfo.put("package", app.packageName);
        appInfo.put("url", app.sourceDir);
        appInfos.add(appInfo);
       }

    return appInfos;
}
 
開發者ID:TIIEHenry,項目名稱:TIIEHenry-Android-SDK,代碼行數:24,代碼來源:AppUtils.java

示例5: isPackageInstalled

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public static boolean isPackageInstalled(Context context, String packageName)
{
	PackageManager pm = context.getPackageManager();
	List<ApplicationInfo> packages = null;

	if (pm != null)
	{
		packages = pm.getInstalledApplications(0);
	}

	if (packages != null)
	{
		for (ApplicationInfo packageInfo : packages)
		{
			if (packageInfo.packageName.equals(packageName))
			{
				return true;
			}
		}
	}

	return false;
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:24,代碼來源:Util.java

示例6: getInstalledApps

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * Retrieves a set of the package names of all non-system applications.
 */
public static Set<String> getInstalledApps(Context context) {
    PackageManager pm = context.getPackageManager();
    List<ApplicationInfo> installedAppInfos =
            pm.getInstalledApplications(PackageManager.GET_META_DATA);

    TreeSet<String> apps = new TreeSet<>();
    for (ApplicationInfo info : installedAppInfos) {
        // ignore self
        if (context.getPackageName().equals(info.packageName)) {
            continue;
        }

        // skip system apps
        if ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
            continue;
        }

        apps.add(info.packageName);
    }

    return apps;
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:26,代碼來源:InstalledAppsUtil.java

示例7: doInBackground

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@Override
protected List<AppInfo> doInBackground(Object... objects) {
  List<AppInfo> labelsPackages = new ArrayList<>();
  PackageManager packageManager = activity.getPackageManager();
  Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
  for (PackageItemInfo appInfo : appInfos) {
    String packageName = appInfo.packageName;
    if (!isHidden(packageName)) {
      CharSequence label = appInfo.loadLabel(packageManager);
      Drawable icon = appInfo.loadIcon(packageManager);        
      if (label != null) {
        labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
      }
    }
  }
  Collections.sort(labelsPackages);
  return labelsPackages;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:19,代碼來源:LoadPackagesAsyncTask.java

示例8: InstalledAppsListAdapter

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@SuppressLint("DefaultLocale")
public InstalledAppsListAdapter(LayoutInflater inflator, PackageManager packageManager, String filter) {
       super();
       this.inflator = inflator;
       this.packageManager = packageManager;
       if( filter == null ) {
       	this.appsInfo = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
       } else {
       	List<ApplicationInfo> tempAppsInfo = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
       	 this.appsInfo = new ArrayList<ApplicationInfo>();
       	 for( ApplicationInfo appInfo : tempAppsInfo ) {
       		 String appName = appInfo.loadLabel(packageManager).toString().toLowerCase();
       		 if(appName.contains(filter.toLowerCase()))
       			 appsInfo.add(appInfo);
       	 }
       }
   }
 
開發者ID:masterjc,項目名稱:bluewatcher,代碼行數:18,代碼來源:InstalledAppsListAdapter.java

示例9: onResume

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@Override
protected void onResume() {
    super.onResume();
    PackageManager packageManager = getPackageManager();
    List<ApplicationInfo> installedApplications = packageManager.getInstalledApplications(0);

    List<ApplicationInfo> debugApps = new ArrayList<>();

    for (ApplicationInfo applicationInfo : installedApplications){
        boolean isDebuggable =  ( 0 != ( applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE));
        if(isDebuggable){
            debugApps.add(applicationInfo);
        }
    }

    adapter.addProcesses(debugApps);
}
 
開發者ID:EmmettWilson,項目名稱:AppTerminator,代碼行數:18,代碼來源:MainActivity.java

示例10: onUpdate

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    PackageManager packageManager = context.getPackageManager();
    List<ApplicationInfo> installedApplications = packageManager.getInstalledApplications(0);
    debugApps = new ArrayList<>();
    for (ApplicationInfo applicationInfo : installedApplications) {
        boolean isDebuggable = (0 != (applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE));
        if (isDebuggable) {
            debugApps.add(applicationInfo);
        }
    }

    for(int widgetId : appWidgetIds){
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);

        setupRemoteViews(context, appWidgetManager, remoteViews, widgetId, 0);
    }
}
 
開發者ID:EmmettWilson,項目名稱:AppTerminator,代碼行數:19,代碼來源:TerminatorWidgetProvider.java

示例11: doInBackground

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@Override
protected List<AppInfo> doInBackground(Object... objects) {
    List<AppInfo> labelsPackages = new ArrayList<>();
    PackageManager packageManager = activity.getPackageManager();
    Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
    for (PackageItemInfo appInfo : appInfos) {
        String packageName = appInfo.packageName;
        if (!isHidden(packageName)) {
            CharSequence label = appInfo.loadLabel(packageManager);
            Drawable icon = appInfo.loadIcon(packageManager);
            if (label != null) {
                labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
            }
        }
    }
    Collections.sort(labelsPackages);
    return labelsPackages;
}
 
開發者ID:xiong-it,項目名稱:ZXingAndroidExt,代碼行數:19,代碼來源:LoadPackagesAsyncTask.java

示例12: onCreate

import android.content.pm.PackageManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the list view to show all the installed apps
    RecyclerView mRecyclerView = findViewById(R.id.main_view);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    // Collect all the apps' info
    ArrayList<OASPVerify> appList = new ArrayList<>();
    PackageManager pm = getPackageManager();
    List<ApplicationInfo> packages = pm.getInstalledApplications(0);
    int isSysApp = ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
    for (ApplicationInfo app : packages) {
        // Ignore system applications
        if ((app.flags & isSysApp) == 0) {
            // Skip the demo app itself
            if (app.packageName.equals(getApplicationContext().getPackageName()))
                continue;
            OASPVerify oaspInfo = new OASPVerify(pm, app);
            dump(oaspInfo);
            appList.add(oaspInfo);
        }
    }

    // Sort app list based on the package name
    Collections.sort(appList, new Comparator<OASPVerify>() {
        @Override
        public int compare(OASPVerify app1, OASPVerify app2) {
            return app1.pkg.compareTo(app2.pkg);
        }
    });

    // Show it
    RecyclerView.Adapter mAdapter = new ListAdapter(appList);
    mRecyclerView.setAdapter(mAdapter);
}
 
開發者ID:baidu,項目名稱:OASP,代碼行數:40,代碼來源:MainActivity.java

示例13: isPackageExists

import android.content.pm.PackageManager; //導入方法依賴的package包/類
static boolean isPackageExists(Context context, String targetPackage) {
    PackageManager pm = context.getPackageManager();
    List<ApplicationInfo> packages = pm.getInstalledApplications(0);
    for (ApplicationInfo packageInfo : packages) {
        if (packageInfo.packageName.equals(targetPackage)) return true;
    }
    return false;
}
 
開發者ID:mgks,項目名稱:Android-SmartWebView,代碼行數:9,代碼來源:UriHelper.java

示例14: startCaching

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * Parse all of the locally installed APKs into a memory cache, starting
 * with the currently selected apps.  APKs that are already parsed in the
 * {@code index.jar} file will be read from that file.
 */
public static void startCaching(Context context) {
    File indexJarFile = LocalRepoManager.get(context).getIndexJar();
    PackageManager pm = context.getPackageManager();
    for (ApplicationInfo applicationInfo : pm.getInstalledApplications(0)) {
        if (applicationInfo.publicSourceDir.startsWith(FDroidApp.SYSTEM_DIR_NAME)) {
            continue;
        }
        if (!indexJarFile.exists()
                || FileUtils.isFileNewer(new File(applicationInfo.sourceDir), indexJarFile)) {
            parseApp(context, applicationInfo.packageName);
        }
    }
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:19,代碼來源:CacheSwapAppsService.java

示例15: isPackageExists

import android.content.pm.PackageManager; //導入方法依賴的package包/類
static boolean isPackageExists(Context context, @SuppressWarnings("SameParameterValue") String targetPackage) {
    PackageManager pm = context.getPackageManager();
    List<ApplicationInfo> packages = pm.getInstalledApplications(0);
    for (ApplicationInfo packageInfo : packages) {
        if (packageInfo.packageName.equals(targetPackage)) return true;
    }
    return false;
}
 
開發者ID:Vorlonsoft,項目名稱:AndroidRate,代碼行數:9,代碼來源:UriHelper.java


注:本文中的android.content.pm.PackageManager.getInstalledApplications方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。