Android的 - 检查的其他应用程序presence [英] Android - check for presence of another app

查看:102
本文介绍了Android的 - 检查的其他应用程序presence的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个应用程序,扩展了另外一个功能,现有的应用程序。我想知道最简单的方法是确定的,通过code,第一个应用程序是否安装,preferably由com.whoever.whatever引用,但几乎所有的标准将是有益的。

解决方案

  android.content.pm.PackageManager MPM = getPackageManager(); // 1
PackageInfo信息= mPm.getPackageInfo(PNAME,0); // 2,3
布尔安装=信息!= NULL;
 


  1. 用在一个活动,你需要一个环境来获得PackageManager
  2. 在抛出 PackageManager.NameNotFoundException ,我猜。检查!
  3. PNAME是像'com.yourcompany.appname,同为一揽子的应用程序的清单
  4. 价值

I'm working on an app that extends the functionality of another, existing app. I want to know what the easiest way is to determine, through code, whether the first app is installed, preferably by referencing it by com.whoever.whatever but almost any criteria would be helpful.

解决方案

android.content.pm.PackageManager mPm = getPackageManager();  // 1
PackageInfo info = mPm.getPackageInfo(pName, 0);  // 2,3
Boolean installed = info != null;


  1. Used in an activity, you need a context to get the PackageManager
  2. Throws PackageManager.NameNotFoundException, I guess. check!
  3. pName is something like 'com.yourcompany.appname', the same as the value of 'package' in the manifest of the app

这篇关于Android的 - 检查的其他应用程序presence的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆