Android之分类获取应用信息

本文详细介绍了Android中获取应用信息的相关类,包括PackageManager、PackageInfo、ResolveInfo、PackageItemInfo及其子类,以及ConfigurationInfo和FeatureInfo,涵盖了从AndroidManifest.xml中解析出来的各种信息,如IntentFilter、硬件配置等。
摘要由CSDN通过智能技术生成

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
 * &lt;intent&gt; 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值