Android跳转到谷歌商店的应用页面

这个需求比较常见。国外项目基本上都会有这个需求,包括更新或者其他的。国内的话可能会要求打开不同的商店(华为、小米等)


 const val googlePlay = "com.android.vending"

 fun transferToGooglePlay(context: Context) {
        try {
            val uri = Uri.parse("market://details?id=" + BuildConfig.APPLICATION_ID)
            val intent = Intent(Intent.ACTION_VIEW, uri)
            intent.setPackage(googlePlay)
            intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
            context.startActivity(intent)
        } catch (e: Exception) {
            Toast.makeText(context, e.toString(), Toast.LENGTH_SHORT).show()
        }
    }

其中googlePlay是谷歌的商店,可以替换成其他的

id 应用市场
com.android.vending Google Play
com.tencent.android.qqdownloader 应用宝
com.qihoo.appstore 360手机助手
com.baidu.appsearch 百度手机助
com.xiaomi.market 小米应用商店
com.wandoujia.phoenix2 豌豆荚
com.huawei.appmarket 华为应用市场
com.taobao.appcenter 淘宝手机助手
com.hiapk.marketpho 安卓市场
cn.goapk.market 安智市场

这里传入的是本应用的applicationId,如果需要跳转的特定的应用页面,需要传入那个应用的applicationID

如果手机上没有对应商店,会弹框让你选择你手机上有的应用商店

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容