Unity3D-Android跳转到指定平台

韦高阳
2023-12-01

华为商店为例

//跳转到指定应用商店,这里以华为为例
public void OnRateToHuawei()
{
    RateToOther("com.google.android.apps.maps", "com.huawei.appmarket");
}

/// 参数
/// appPkg: 你需要跳转到的App应用
/// marketPkg: 应用商店的PackageName
public static void RateToOther(string appPkg, string marketPkg)
{
    if (!Application.isEditor)
    {
        AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
        AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
        intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_VIEW"));
        AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
        AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "market://details?id=" + appPkg);
        intentObject.Call<AndroidJavaObject>("setData", uriObject);
        intentObject.Call<AndroidJavaObject>("setPackage", marketPkg);
        AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
        currentActivity.Call("startActivity", intentObject);
    }
}

天朝各应用商店的PackageName

应用商店应用包名
腾讯应用宝com.tencent.android.qqdownloader
360手机助手com.qihoo.appstore
百度手机助手com.baidu.appsearch
小米应用商店com.xiaomi.market
华为应用商店com.huawei.appmarket
Google Play Storecom.android.vending
魅族应用市场com.meizu.mstore
豌豆荚com.wandoujia.phoenix2
91手机助手com.dragon.android.pandaspace
PP手机助手com.pp.assistant
OPPO应用商店com.oppo.market
VIVO应用商店com.bbk.appstore
搜狗应用市场com.sogou.androidtool
三星应用商店com.sec.android.app.samsungapps
联想应用商店com.lenovo.leos.appstore
中兴应用商店zte.com.market
安智应用商店com.hiapk.marketpho
应用汇com.yingyonghui.market
机锋应用市场com.mappn.gfan
安卓市场com.hiapk.marketpho
GO商店cn.goapk.market
酷派应用商店com.yulong.android.coolmart
酷市场com.coolapk.market
金立软件商店com.gionee.aora.market

https://blog.csdn.net/pz789as/article/details/78223517
https://www.jianshu.com/p/cfb7f212a5a2

 类似资料: