【0】我们可以使用getPackageManager() 方法来查询安装在系统上的AP.

public abstract class

PackageManager

extends Object
java.lang.Object
android.content.pm.PackageManager
Known Direct Subclasses MockPackageManager
Class for retrieving various kinds of information related to the application packages that are currently installed on the device. You can find this class throughgetPackageManager(). 【1】使用从Manifest.xml文件中获得到的PackageInfo来取得AP的信息. public class

PackageInfo

extends Object
implements Parcelable
java.lang.Object
android.content.pm.PackageInfo

Overall information about the contents of a package. This corresponds to all of the information collected from AndroidManifest.xml.

public static finalCreator<PackageInfo>CREATOR

Since: API Level 1

publicActivityInfo[]activities

Since: API Level 1

Array of all<activity>tags included under <application>, or null if there were none. This is only filled in if the flagGET_ACTIVITIESwas set.

publicApplicationInfoapplicationInfo

Since: API Level 1

Information collected from the <application> tag, or null if there was none.

publicConfigurationInfo[]configPreferences

Since: API Level 3

Application specified preferred configuration<uses-configuration>tags included under <manifest>, or null if there were none. This is only filled in if the flagGET_CONFIGURATIONSwas set.

public longfirstInstallTime

Since: API Level 9

The time at which the app was first installed. Units are as percurrentTimeMillis().

public int[]gids

Since: API Level 1

All kernel group-IDs that have been assigned to this package. This is only filled in if the flagGET_GIDSwas set.

publicInstrumentationInfo[]instrumentation

Since: API Level 1

Array of all<instrumentation>tags included under <manifest>, or null if there were none. This is only filled in if the flagGET_INSTRUMENTATIONwas set.

public longlastUpdateTime

Since: API Level 9

The time at which the app was last updated. Units are as percurrentTimeMillis().

publicStringpackageName

Since: API Level 1

The name of this package. From the <manifest> tag's "name" attribute.

publicPermissionInfo[]permissions

Since: API Level 1

Array of all<permission>tags included under <manifest>, or null if there were none. This is only filled in if the flagGET_PERMISSIONSwas set.

publicProviderInfo[]providers

Since: API Level 1

Array of all<provider>tags included under <application>, or null if there were none. This is only filled in if the flagGET_PROVIDERSwas set.

publicActivityInfo[]receivers

Since: API Level 1

Array of all<receiver>tags included under <application>, or null if there were none. This is only filled in if the flagGET_RECEIVERSwas set.

publicFeatureInfo[]reqFeatures

Since: API Level 5

The features that this application has said it requires.

publicString[]requestedPermissions

Since: API Level 1

Array of all<uses-permission>tags included under <manifest>, or null if there were none. This is only filled in if the flagGET_PERMISSIONSwas set. This list includes all permissions requested, even those that were not granted or known by the system at install time.

publicServiceInfo[]services

Since: API Level 1

Array of all<service>tags included under <application>, or null if there were none. This is only filled in if the flagGET_SERVICESwas set.

publicStringsharedUserId

Since: API Level 3

The shared user ID name of this package, as specified by the <manifest> tag'ssharedUserIdattribute.

public intsharedUserLabel

Since: API Level 3

The shared user ID label of this package, as specified by the <manifest> tag'ssharedUserLabelattribute.

publicSignature[]signatures

Since: API Level 1

Array of all signatures read from the package file. This is only filled in if the flagGET_SIGNATURESwas set.

public intversionCode

Since: API Level 1

The version number of this package, as specified by the <manifest> tag'sversionCodeattribute.

publicStringversionName

Since: API Level 1

The version name of this package, as specified by the <manifest> tag'sversionNameattribute.

【2】使用上面两个类来实现一个判断某个AP是否安装在系统中的工具类

  
      

public abstractList<PackageInfo>getInstalledPackages(int flags)

Since: API Level 1

Return a List of all packages that are installed on the device.

Parameters
flags
Additional option flags. Use any combination ofGET_ACTIVITIES,GET_GIDS,GET_CONFIGURATIONS,GET_INSTRUMENTATION,GET_PERMISSIONS,GET_PROVIDERS,GET_RECEIVERS,GET_SERVICES,GET_SIGNATURES,GET_UNINSTALLED_PACKAGESto modify the data returned.
Returns
  • A List of PackageInfo objects, one for each package that is installed on the device. In the unlikely case of there being no installed packages, an empty list is returned. If flag GET_UNINSTALLED_PACKAGES is set, a list of all applications including those deleted with DONT_DELETE_DATA (partially installed apps with data directory) will be returned.


谢谢!

更多相关文章

  1. Android(安卓)GPS获得经纬度并得到该坐标精确地址
  2. android如何往SDCard中存取图片
  3. android 使用post方式上传文件
  4. android 中 LocalSocket的基本使用方法
  5. Android经常使用开源组件汇总
  6. 箭头函数的基础使用
  7. NPM 和webpack 的基础使用
  8. Python list sort方法的具体使用
  9. 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程

随机推荐

  1. MySQL8.0新特性之支持原子DDL语句
  2. mysql存储emoji表情报错的处理方法【更改
  3. MySQL无法存储Emoji表情问题的解决方法分
  4. MYSQL配置参数优化详解
  5. redis服务器环境下mysql实现lnmp架构缓存
  6. Ubuntu 18.04配置mysql以及配置远程连接
  7. mysql存储过程基础之遍历多表记录后插入
  8. mysql实现查询结果导出csv文件及导入csv
  9. mysql实现查询最接近的记录数据示例
  10. mysql多个left join连接查询用法分析