当前位置: 首页>>代码示例>>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;未经允许,请勿转载。