【Android】判断某个AP是否在系统中存在(PackageManager与PackageInfo)
来源:互联网 发布:mac央视影音播放器 编辑:程序博客网 时间:2024/05/03 13:18
【0】我们可以使用 getPackageManager() 方法来查询安装在系统上的AP.
PackageManager
extends ObjectgetPackageManager()
.PackageInfo
extends Objectimplements Parcelable
Overall information about the contents of a package. This corresponds to all of the information collected from AndroidManifest.xml.
public static final Creator<PackageInfo> CREATOR
public ActivityInfo[] activities
Array of all <activity>
tags included under <application>, or null if there were none. This is only filled in if the flag GET_ACTIVITIES
was set.
public ApplicationInfo applicationInfo
Information collected from the <application> tag, or null if there was none.
public ConfigurationInfo[] configPreferences
Application specified preferred configuration <uses-configuration>
tags included under <manifest>, or null if there were none. This is only filled in if the flag GET_CONFIGURATIONS
was set.
public long firstInstallTime
The time at which the app was first installed. Units are as per currentTimeMillis()
.
public int[] gids
All kernel group-IDs that have been assigned to this package. This is only filled in if the flag GET_GIDS
was set.
public InstrumentationInfo[] instrumentation
Array of all <instrumentation>
tags included under <manifest>, or null if there were none. This is only filled in if the flag GET_INSTRUMENTATION
was set.
public long lastUpdateTime
The time at which the app was last updated. Units are as per currentTimeMillis()
.
public String packageName
The name of this package. From the <manifest> tag's "name" attribute.
public PermissionInfo[] permissions
Array of all <permission>
tags included under <manifest>, or null if there were none. This is only filled in if the flag GET_PERMISSIONS
was set.
public ProviderInfo[] providers
Array of all <provider>
tags included under <application>, or null if there were none. This is only filled in if the flag GET_PROVIDERS
was set.
public ActivityInfo[] receivers
Array of all <receiver>
tags included under <application>, or null if there were none. This is only filled in if the flag GET_RECEIVERS
was set.
public FeatureInfo[] reqFeatures
The features that this application has said it requires.
public String[] requestedPermissions
Array of all <uses-permission>
tags included under <manifest>, or null if there were none. This is only filled in if the flag GET_PERMISSIONS
was set. This list includes all permissions requested, even those that were not granted or known by the system at install time.
public ServiceInfo[] services
Array of all <service>
tags included under <application>, or null if there were none. This is only filled in if the flag GET_SERVICES
was set.
public String sharedUserId
The shared user ID name of this package, as specified by the <manifest> tag's sharedUserId
attribute.
public int sharedUserLabel
The shared user ID label of this package, as specified by the <manifest> tag's sharedUserLabel
attribute.
public Signature[] signatures
Array of all signatures read from the package file. This is only filled in if the flag GET_SIGNATURES
was set.
public int versionCode
The version number of this package, as specified by the <manifest> tag's versionCode
attribute.
public String versionName
The version name of this package, as specified by the <manifest> tag's versionName
attribute.
/** * Whether the AP was installed * @param context:the Context * @param packageName:the ap packageName * @return */public static boolean isAppInstalled(Context context, String packageName){//获取到一个PackageManager的instancefinal PackageManager packageManager = context.getPackageManager();//PERMISSION_GRANTED = 0List<PackageInfo> mPackageInfo = packageManager.getInstalledPackages(0);boolean flag = false;if(mPackageInfo != null){String tempName = null;for(int i = 0; i < mPackageInfo.size(); i++){//获取到AP包名tempName = mPackageInfo.get(i).packageName;if(tempName != null && tempName.equals(packageName)){MyLogger.kLog().i("Package[" + packageName + "]:is installed.");flag = true;break;}}}return flag;}
public abstract List<PackageInfo> getInstalledPackages (int flags)
Return a List of all packages that are installed on the device.
Parameters
GET_ACTIVITIES
, GET_GIDS
, GET_CONFIGURATIONS
, GET_INSTRUMENTATION
, GET_PERMISSIONS
,GET_PROVIDERS
, GET_RECEIVERS
, GET_SERVICES
, GET_SIGNATURES
, GET_UNINSTALLED_PACKAGES
to 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.
谢谢!
- 【Android】判断某个AP是否在系统中存在(PackageManager与PackageInfo)
- 利用PackageManager判断系统中是否存在与Intent匹配的组件
- T-SQL判断某个表在ACCESS中是否存在及查看ACCESS中的系统表
- Android中PackageManager学习笔记(2)-PackageInfo
- 在脚本(script)中判断某个命令是否存在
- JS 判断某个字符串是否存在与数组中
- Android 判断数据库中是否存在某个表
- android sqlite中判断某个表是否存在
- Android sqlite中判断某个表是否存在
- Android 判断数据库中是否存在某个表
- Android判断asset中是否存在某个文件
- 查询android系统中是否存在某个APK
- [Android]判断本地是否存在某个APP
- 判断数据库中是否存在某个表
- 判断dataset中是否存在某个表?
- 判断ACCESS中是否存在某个表
- 判断字符串中是否存在某个字符
- 判断应用中某个activity是否存在
- eclipse中 对工程中部分js文件中的错误不进行提示,不在文件名或工程上有错误提示
- 创建Delphi向导
- JS做的鼠标拖动翻页效果
- mssql将竖表转化成横表
- JS控制图片拖动 放大 缩小 旋转
- 【Android】判断某个AP是否在系统中存在(PackageManager与PackageInfo)
- 判断是否为图片
- android 判断wifi网络是否链接
- java equal&&==的区别
- ExtJS中九种布局方式
- 高端内存
- 《家庭账本管理》小程序,业务表格草稿
- Js实现无刷新添加新层,拖动DIV层可互换位置丨www.CsrCode.cn
- android 判断3G网络是否链接