下载应用程序,如果没有安装意向 [英] Download app if intent not installed

查看:93
本文介绍了下载应用程序,如果没有安装意向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我已经看到了调用一个意图的一种方式,如果不存在,该函数将重定向到市场下载,有意向的应用程序。

I know I have seen a way of calling an Intent, and if it doesn't exist the function will redirect to market for download the application that has the intent.

现在,我检查,如果存在的意图,但我不知道如何给用户指向下载的资源。

Right now I check if the Intent exists but I don't know how to point the user to the resource to download.

在此先感谢

推荐答案

要检查是否某些意图可用:

To check if some Intent is available:

String intentToCheck = "com.google.SCAN"; //can be any other intent
final PackageManager packageManager = getPackageManager();
final Intent intent = new Intent(intentToCheck);
List list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
final boolean isAvailable = list.size() > 0;

要通过意图打开谷歌市场:

To open Google Market via Intent:

Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:com.google.scan"));
startActivity(marketIntent); 

这篇关于下载应用程序,如果没有安装意向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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