安卓开发中,判断是否安装了qq
在安卓手机app开发中,能否通过设置一个按键,来判断手机中是否安装了qq;如果安装了qq,打开qq。这样的功能应该怎么实现,题主安卓开发小白,希望大神们能够解答详尽一些,...
在安卓手机app开发中,能否通过设置一个按键,来判断手机中是否安装了qq;如果安装了qq,打开qq。这样的功能应该怎么实现,题主安卓开发小白,希望大神们能够解答详尽一些,感激不尽
搜索
复制 展开
搜索
复制 展开
展开全部
Android系统中,判断应用有无安装有两种方式:
1.根据包名判断,以下为判断代码:
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager()
.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
2. 根据Intent判断,以下为判断代码:
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, 0);
if(list.size() > 0){
return true;
}
return false;
}
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName)) return false;
try {
ApplicationInfo info = context.getPackageManager() .getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); return true;
} catch (NameNotFoundException e) { return false; }
}
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = context.getPackageManager()
.queryIntentActivities(intent, 0);
if (list.size() > 0) {
return true;
}
return false;
}
1.根据包名判断,以下为判断代码:
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager()
.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
2. 根据Intent判断,以下为判断代码:
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, 0);
if(list.size() > 0){
return true;
}
return false;
}
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName)) return false;
try {
ApplicationInfo info = context.getPackageManager() .getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); return true;
} catch (NameNotFoundException e) { return false; }
}
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = context.getPackageManager()
.queryIntentActivities(intent, 0);
if (list.size() > 0) {
return true;
}
return false;
}
展开全部
Android系统中,判断应用有无安装有两种方式:
1.根据包名判断,以下为判断代码:
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager()
.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
2. 根据Intent判断,以下为判断代码:
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, 0);
if(list.size() > 0){
return true;
}
return false;
}
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName)) return false;
try {
ApplicationInfo info = context.getPackageManager() .getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); return true;
} catch (NameNotFoundException e) { return false; }
}
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = context.getPackageManager()
.queryIntentActivities(intent, 0);
if (list.size() > 0) {
return true;
}
return false;
}
1.根据包名判断,以下为判断代码:
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager()
.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
2. 根据Intent判断,以下为判断代码:
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, 0);
if(list.size() > 0){
return true;
}
return false;
}
public boolean checkApkExist(Context context, String packageName) {
if (packageName == null || “”.equals(packageName)) return false;
try {
ApplicationInfo info = context.getPackageManager() .getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); return true;
} catch (NameNotFoundException e) { return false; }
}
public boolean checkApkExist(Context context, Intent intent) {
List<ResolveInfo> list = context.getPackageManager()
.queryIntentActivities(intent, 0);
if (list.size() > 0) {
return true;
}
return false;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public static final boolean isApkInstalled(Context context, String packageName) {
try {
context.getPackageManager().getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
packageName = "com.tencent.mobileqq"
try {
context.getPackageManager().getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
packageName = "com.tencent.mobileqq"
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询