Get mobile app Information

Source: Internet
Author: User

SystemUtils. java tool class [java] package com. techrare. utils; import java. util. arrayList; import java. util. list; import android. content. context; import android. content. intent; import android. content. pm. packageInfo; import android. content. pm. packageManager; import android. content. pm. resolveInfo; /*** get mobile app information ** @ author Administrator **/public class SystemUtils {/*** query all apps in the mobile phone, including System Applications * @ param context */public static List <PackageInfo> getAllApps (Context context) {PackageManager pManager = context. getPackageManager (); // obtain the List of all applications in the mobile phone. <PackageInfo> paklist = pManager. getInstalledPackages (0); return paklist;}/*** query non-system applications in the mobile phone * @ param context * @ return */public static List <PackageInfo> getall1_nosystem (Context context) {List <PackageInfo> apps = new ArrayList <PackageInfo> (); PackageManager pManager = context. getPackageManager (); // obtain the List of all applications in the mobile phone. <PackageInfo> paklist = pManager. getInstalledPackages (0); for (int I = 0; I <paklist. size (); I ++) {PackageInfo pak = (PackageInfo) paklist. get (I); // determine whether the application is not pre-installed by the system if (pak. applicationInfo. flags & pak. applicationInfo. FLAG_SYSTEM) <= 0) {// customs applications apps. add (pak) ;}} return apps ;} /*** query all apps that support sharing on the mobile phone * @ param context * @ return */public static List <ResolveInfo> getmediaapps (Context context) {List <ResolveInfo> mApps = new ArrayList <ResolveInfo> (); Intent intent = new Intent (Intent. ACTION_SEND, null); intent. addCategory (Intent. CATEGORY_DEFAULT); intent. setType ("text/plain"); PackageManager pManager = context. getPackageManager (); mApps = pManager. queryIntentActivities (intent, PackageManager. COMPONENT_ENABLED_STATE_DEFAULT); return mApps;}/* remarks: Use PackageInfo to obtain information. Method: packageInfo. how to obtain packageName icon: packageManager. getApplicationIcon (applicationInfo): packageManager. getApplicationLabel (applicationInfo) Permission acquisition method: packageManager. getPackageInfo (packageName, PackageManager. GET_PERMISSIONS ). requestedPermissions obtain detailed information through ResolveInfo method: package name acquisition method: resolve. activityInfo. how to obtain packageName icon: resolve. loadIcon (packageManager) Application name acquisition method: resolve. loadLabel (packageManager ). toString ()*/}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.