Android之分类获取应用信息
相关类介绍:
PackageManager
/** * Class for retrieving various kinds of information related to the application * packages that are currently installed on the device. * * You can find this class through { @link Context#getPackageManager}. */ public abstract class PackageManager {
获取:
context.getPackageManager()
PackageInfo
/** * Overall information about the contents of a package. This corresponds * to all of the information collected from AndroidManifest.xml. */ public class PackageInfo implements Parcelable {
解释:这个类包含所有AndroidManifest.xml中定义的信息,通过它就可以获取到AndroidManifest.xml中的信息。
获取:
// 获取手机内所有应用 List<PackageInfo> paklist = context.getPackageManager().getInstalledPackages(0);
ResolveInfo
/** * Information that is returned from resolving an intent * against an IntentFilter. This partially corresponds to * information collected from the AndroidManifest.xml's * <intent> tags. */ public class ResolveInfo implements Parcelable {
解释:这个解析AndroidManifest.xml中的IntentFilter定义的信息,包含一些AndroidManifest.xml标签Intent的信息,所以信息不全部是Intent的信息。
获取:
Intent intent = new Intent(Intent.ACTION_MAIN,null); intent.addCategory(Intent.CATEGORY_LAUNCHER); List< ResolveInfo> appList1 = context.getPackageManager().queryIntentActivities(intent,0);
PackageItemInfo
/** * Base class containing information common to all package items held by * the package manager. This provides a very common basic set of attributes: * a label, icon, and meta-data. This class is not intended * to be used by itself; it is simply here to share common definitions * between all items returned by the package manager. As such, it does not