如何确定使用哪个安卓市场下载了我的应用程序

4

我计划不仅在Google Play上分发我的应用程序,还要在其他几个市场上分发,如Opera Mobile Store、Yandex Store、Amazon App Store。对于“评价”按钮,我需要链接到商店页面。是否可能找出使用哪个市场下载了我的应用程序?

当然,我可以为每个市场编译单独的APK,但我想制作一个通用的APK。不同的IAP APIs通过OpenIAB库解决,但现在我遇到了与市场链接的问题。

1个回答

5

通常,如果你使用一些广告来推广你的应用程序,你可以使用谷歌的一些工具:

简而言之,你需要在你的应用程序中插入Google Analytics(如果你还没有使用它的话),并使用它的工具,称为:

Campaign Measurement

然后你可以注册安装的接收器:

<receiver
        android:name=".system.RefferReceiver"
        android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>

您可以在接收器内处理逻辑:

public class RefferReceiver extends BroadcastReceiver {

@Override
public void onReceive(final Context context, Intent intent) {
    String referrer = intent.getStringExtra("referrer");
    //do some logic
}

抱歉,我没有仔细阅读你的问题。如果你只想知道你的应用程序的市场来源,你可以使用:
 String installerMarket = getPackageManager().getInstallerPackageName("your_package_name");
    if (installerMarket == null){
        //do some default case
    }
    else if ("com.android.vending".equals(installerMarket)) {
        //link to google play
    } else  if ("com.amazon.venezia".equals(installerMarket)){
        //link to amazon
    } else if //you got the idea, you need to know the name of every market  store installer
    }

但它只能与Google Play服务一起使用,对吧?如果应用程序不是通过Google Play安装的,就不会收到引荐者信息了? - Roman Shuvalov

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接