阅读:5478回复:1

安卓Launcher启动未安装的APK自动跳转到谷歌商店下载

楼主#
更多 发布于:2019-07-03 10:42
在做安卓盒子Launcher时,很多桌面的APK的图标是固定的,客户要求点击图标时,若APK已经安装,则直接打开,若没有安装,就自动打开谷歌商店下载这个APK。打开谷歌商店下载APK的代码如下:




public static void launchAppDetail(String appPkg) { // appPkg 是应用的包名
 final String GOOGLE_PLAY = "com.android.vending";// 这里对应的是谷歌商店,跳转别的商店改成对应的即可
 try {
 if (TextUtils.isEmpty(appPkg))
 return;
 Uri uri = Uri.parse("market://details?id=" + appPkg);
 Intent intent = new Intent(Intent.ACTION_VIEW, uri);
 intent.setPackage(GOOGLE_PLAY);
 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 mContext.startActivity(intent);
 } catch (Exception e) {
 }
 }

最新喜欢:

VastStarGamesVastSt...
[url]http://190.lsal.cn/195/1329.gif?0728100424873[/url]
沙发#
发布于:2019-07-03 16:38
不错,经常碰到的
If you have nothing to lose, then you can do anything.
游客

返回顶部