Android打開應用市場


原本區分應用渠道跳轉不同應用市場,但是在小米手機上出現了無響應的情況,最終放棄了跳轉指定應用市場的方法,改為僅做跳轉不做控制;

String pkgName = context.getPackageName();
Uri uri = Uri.parse("market://details?id=" + pkgName);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
try {
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return true;
} catch (Exception e) {
    return false;
}

原本的跳轉區分:

 when (channelId) {
    "oppo" -> {
        chanelName = "OPPO應用商店"
        intent.setClassName("com.oppo.market", "a.a.a.aoz")
    }
    "vivo" -> {
        chanelName = "VIVO應用商店"
        intent.setClassName("com.bbk.appstore", "com.bbk.appstore.ui.AppStoreTabActivity")
    }
    "baidu" -> {
        chanelName = "百度手機助手"
        intent.setPackage("com.baidu.appsearch")
    }
    "anzhi" -> {
        chanelName = "cn.goapk.market"
        intent.setPackage("安智市場")
    }
    "huawei" -> {
        chanelName = "華為應用市場"
        intent.setClassName("com.huawei.appmarket", "com.huawei.appmarket.service.externalapi.view.ThirdApiActivity")
    }
    "xiaomi" -> {
        chanelName = "小米應用商店"
        intent.setClassName("com.xiaomi.market", "com.xiaomi.market.ui.AppDetailActivity")
    }
    "meizu" -> {
        chanelName = "魅族應用商店"
        intent.setClassName("com.meizu.mstore", "com.meizu.flyme.appcenter.activitys.AppMainActivity")
    }
    "samsung" -> {
        chanelName = ""
        intent.data = Uri.parse("http://www.samsungapps.com/appquery/appDetail.as?appId=$apkName")
        intent.setClassName("com.sec.android.app.samsungapps", "com.sec.android.app.samsungapps.Main")
    }
    "360" -> {
        chanelName = "360手機助手"
        intent.setClassName("com.qihoo.appstore", "com.qihoo.appstore.distribute.SearchDistributionActivity")
    }
    "yingyongbao" -> {
        chanelName = "應用寶"
        intent.setClassName("com.tencent.android.qqdownloader", "com.tencent.pangu.link.LinkProxyActivity")
    }
    "wandoujia" -> {
        chanelName = "豌豆莢"
        intent.setClassName("com.wandoujia.phoenix2", "com.pp.assistant.activity.PPMainActivity")
    }
    "pp" -> {
        chanelName = "PP助手"
        intent.setClassName("com.pp.assistant", "com.pp.assistant.activity.MainActivity")
    }
    "ali" -> {//pp助手,豌豆莢,淘寶手機助手,九游,UC應用商城,神馬搜索
        //TODO
        chanelName = "應用市場"
          intent.setPackage("")
    }
    else -> {
        chanelName = "應用寶"
        intent.setClassName("com.tencent.android.qqdownloader", "com.tencent.pangu.link.LinkProxyActivity")
    }
}

2020-04-26


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM