从Android Market安装app后获得推荐

时间:2023-01-16 15:22:31

I am trying to register a Broadcast Receiver that catches "com.android.vending.INSTALL_REFERRER" intents launched by Android after an app is installed from the Market.

我正在尝试注册一个广播接收器,捕捉“com. android.售货机”。“安装推荐”是Android在市场上安装了应用程序后发布的意图。

I am following the details here: http://code.google.com/mobile/analytics/docs/android/#referrals

下面是一些细节:http://code.google.com/mobile/analytics/docs/android/#referrals

However, I cannot use Google Analytics so I have created my own solution. I have added the following to my manifest file:

但是,我不能使用谷歌分析,所以我创建了自己的解决方案。我已将下列文件添加到我的清单文件:

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

and created a basic BroadcastReceiver class:

并创建了一个基本的BroadcastReceiver类:

public class Receiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        Bundle extras = intent.getExtras();
        String referrerString = extras.getString("referrer");

        Log.w("TEST", "Referrer is: " + referrerString);
    }
}

However, when the app is installed the receiver doesn't seem to catch the Intent (if the Intent is even broadcast?) and I get no logging output.

然而,当应用程序安装时,接收器似乎没有捕捉到意图(如果意图甚至是广播?),我就没有日志输出。

Am I going wrong somewhere or is the Market no longer launching these Intents when an app is installed?

我是不是做错了什么,或者市场不再在安装应用程序时发布这些意图了?

8 个解决方案

#1


46  

I would try to help who, like me, fails to make install_referrer work and who don't find ANY useful information about these features.

我将尽力帮助那些像我一样不能使用install_referrer的人,以及那些没有找到关于这些特性的任何有用信息的人。

Notes:

注:

  1. The intent com.android.vending.INSTALL_REFERRER will be caught during the install process, not when the application starts for the first time.
  2. 了com.android.vending意图。安装过程中将捕获INSTALL_REFERRER,而不是应用程序第一次启动时。
  3. The referrer ...extras.getString("referrer").. is fixed but the contents can be any string value that respect the http get syntax ...referrer=thatsthevalue&thisisnot=xxx
  4. 上线…extras.getString(“推荐人”). .是固定的,但是内容可以是任何与http get语法相关的字符串值…referrer=thatsthevalue&thisisnot=xxx

The above code is okay, just some explanations to complete the info:

上面的代码是可以的,只是一些解释来完成信息:

  1. Android Manifest. The <receiver> tags must be inside the <application> tags.
  2. Android清单。 标签必须在 标签中。
  3. The correct url to link the market is not the results of the famous google forms in sdk
  4. 链接市场的正确url不是sdk中著名的谷歌表单的结果

but this one

但是这一次

http://market.android.com/details?id=your.application.package.name&referrer=my_referrer_finally_works_fine

http://market.android.com/details?id=your.application.package.name&referrer=my_referrer_finally_works_fine

Obviously, you need to follow the link from the mobile device and the only way for a complete test is to publish a test application in the market.

显然,您需要遵循移动设备的链接,而完整测试的唯一方法是在市场上发布测试应用程序。

And a final and personal note.

以及最后的个人笔记。

I don't understand why those info are omitted completely and i hope that Google will act for detailing it.

我不明白为什么这些信息被完全忽略了,我希望谷歌能详细说明。

#2


16  

This might be a little late, but you CAN test the install referrer without using Google Play, just use ADB :)

这可能有点晚了,但是您可以在不使用谷歌Play的情况下测试安装引用,只需使用ADB:)

Run this from adb.exe

运行这个从adb.exe

adb shell

am broadcast -a com.android.vending.INSTALL_REFERRER -n your.package/path.to.your.BroadcastReceiver --es "referrer" "test_referrer=test"

If you have logging setup in your BroadcastReceiver, you will see it popup in LogCat.

如果在BroadcastReceiver中有登录设置,则会在LogCat中看到它弹出。

Hope this helps!

希望这可以帮助!

#3


5  

Okay so I found the reason why the Intent wasn't being launched. Apparently you MUST use the same parameter names as outlined here: http://code.google.com/mobile/analytics/docs/android/#referrals

我找到了为什么意图没有被启动的原因。显然,您必须使用这里列出的参数名称:http://code.google.com/mobile/analytics/docs/android/#referrals

You cant use your own parameter names as I was doing :S

你不能像我一样使用你自己的参数名:S

#4


5  

I think these answers must have been written pre-Android 3.1 - because things have changed in one import way.

我认为这些答案一定是在android 3.1之前写的——因为事情在某种意义上发生了变化。

The system now marks app as dormant when they are installed - they won't receive INSTALL_REFERRER or any other broadcast until the user explicitly activates the app by running it (or placing widget).

该系统现在将应用程序标记为休眠状态——在用户通过运行(或放置小部件)显式激活应用程序之前,它们不会接收到INSTALL_REFERRER或任何其他广播。

#5


2  

I agree that Google's documentation isn't the best. However, I've only been able to get the intent to fire by actually uploading the app to the Market Place and then downloading/installing it. The intent does launch immediately after the download/instal - the user does not have to start the app. I'm using this to start a background service as well.

我同意谷歌的文档不是最好的。然而,我只能通过将应用程序上传到市场上,然后下载/安装它,才能够达到目的。意图在下载/安装后立即启动——用户不需要启动应用程序。我也用这个启动后台服务。

#6


2  

Please notice that this is not the first start intent but only a android market related intent which is sent my the google android market. If you install the app through a different resource than the android market it will not fire.

请注意,这不是我的第一个开始意图,而是一个android市场相关的意图,它发送给我的谷歌android市场。如果你通过不同于android市场的资源来安装这个应用程序,它就不会启动。

Use the link which you can build there: http://code.google.com/mobile/analytics/docs/android/#android-market-tracking get the referrer from the intent and take it apart to get the different parameters

使用你可以在那里建立的链接:http://code.google.com/mobile/analytics/docs/android/#android-market-tracking从意图中获取引用并将其分解以获得不同的参数

referrer = intent.getStringExtra("referrer");
Map<String, String> params = Toolbox.getQueryMap(referrer);

P.S. You don't need to read to read the deviceid/IMEI to do this, as some apps do. You shouldn't want to spy out your users.

附注:你不需要阅读deviceid/IMEI就能做到这一点,就像有些应用一样。你不应该想要监视你的用户。

#7


1  

Actually there could be any links like market://... or http://market... either work fine. Also it doesn't matter what kind of parameters will be in the referrer field. It works fine with any text in there.

实际上可以有任何类似市场的链接://…或http://market..。要么工作好。另外,在引用字段中包含哪些参数也无关紧要。它适用于任何文本。

The main issue that this event type "com.android.vending.INSTALL_REFERRER" doesn't send by broadcast. This event goes ONLY into the just installed application.

这个事件类型的主要问题是“com. android.售货机”。INSTALL_REFERRER“不会通过广播发送。此事件仅进入刚刚安装的应用程序。

UPD: And there only one way to test it - deploy your App into the Market and then install it on the phone.

UPD:只有一种测试方法——把你的应用程序部署到市场上,然后把它安装到手机上。

#8


0  

Use Google Play Referrer API (from 20 Nov 2017) very easily and securely as i answered here

使用谷歌播放引用API(从2017年11月20日开始)非常容易和安全,正如我在这里回答的

#1


46  

I would try to help who, like me, fails to make install_referrer work and who don't find ANY useful information about these features.

我将尽力帮助那些像我一样不能使用install_referrer的人,以及那些没有找到关于这些特性的任何有用信息的人。

Notes:

注:

  1. The intent com.android.vending.INSTALL_REFERRER will be caught during the install process, not when the application starts for the first time.
  2. 了com.android.vending意图。安装过程中将捕获INSTALL_REFERRER,而不是应用程序第一次启动时。
  3. The referrer ...extras.getString("referrer").. is fixed but the contents can be any string value that respect the http get syntax ...referrer=thatsthevalue&thisisnot=xxx
  4. 上线…extras.getString(“推荐人”). .是固定的,但是内容可以是任何与http get语法相关的字符串值…referrer=thatsthevalue&thisisnot=xxx

The above code is okay, just some explanations to complete the info:

上面的代码是可以的,只是一些解释来完成信息:

  1. Android Manifest. The <receiver> tags must be inside the <application> tags.
  2. Android清单。 标签必须在 标签中。
  3. The correct url to link the market is not the results of the famous google forms in sdk
  4. 链接市场的正确url不是sdk中著名的谷歌表单的结果

but this one

但是这一次

http://market.android.com/details?id=your.application.package.name&referrer=my_referrer_finally_works_fine

http://market.android.com/details?id=your.application.package.name&referrer=my_referrer_finally_works_fine

Obviously, you need to follow the link from the mobile device and the only way for a complete test is to publish a test application in the market.

显然,您需要遵循移动设备的链接,而完整测试的唯一方法是在市场上发布测试应用程序。

And a final and personal note.

以及最后的个人笔记。

I don't understand why those info are omitted completely and i hope that Google will act for detailing it.

我不明白为什么这些信息被完全忽略了,我希望谷歌能详细说明。

#2


16  

This might be a little late, but you CAN test the install referrer without using Google Play, just use ADB :)

这可能有点晚了,但是您可以在不使用谷歌Play的情况下测试安装引用,只需使用ADB:)

Run this from adb.exe

运行这个从adb.exe

adb shell

am broadcast -a com.android.vending.INSTALL_REFERRER -n your.package/path.to.your.BroadcastReceiver --es "referrer" "test_referrer=test"

If you have logging setup in your BroadcastReceiver, you will see it popup in LogCat.

如果在BroadcastReceiver中有登录设置,则会在LogCat中看到它弹出。

Hope this helps!

希望这可以帮助!

#3


5  

Okay so I found the reason why the Intent wasn't being launched. Apparently you MUST use the same parameter names as outlined here: http://code.google.com/mobile/analytics/docs/android/#referrals

我找到了为什么意图没有被启动的原因。显然,您必须使用这里列出的参数名称:http://code.google.com/mobile/analytics/docs/android/#referrals

You cant use your own parameter names as I was doing :S

你不能像我一样使用你自己的参数名:S

#4


5  

I think these answers must have been written pre-Android 3.1 - because things have changed in one import way.

我认为这些答案一定是在android 3.1之前写的——因为事情在某种意义上发生了变化。

The system now marks app as dormant when they are installed - they won't receive INSTALL_REFERRER or any other broadcast until the user explicitly activates the app by running it (or placing widget).

该系统现在将应用程序标记为休眠状态——在用户通过运行(或放置小部件)显式激活应用程序之前,它们不会接收到INSTALL_REFERRER或任何其他广播。

#5


2  

I agree that Google's documentation isn't the best. However, I've only been able to get the intent to fire by actually uploading the app to the Market Place and then downloading/installing it. The intent does launch immediately after the download/instal - the user does not have to start the app. I'm using this to start a background service as well.

我同意谷歌的文档不是最好的。然而,我只能通过将应用程序上传到市场上,然后下载/安装它,才能够达到目的。意图在下载/安装后立即启动——用户不需要启动应用程序。我也用这个启动后台服务。

#6


2  

Please notice that this is not the first start intent but only a android market related intent which is sent my the google android market. If you install the app through a different resource than the android market it will not fire.

请注意,这不是我的第一个开始意图,而是一个android市场相关的意图,它发送给我的谷歌android市场。如果你通过不同于android市场的资源来安装这个应用程序,它就不会启动。

Use the link which you can build there: http://code.google.com/mobile/analytics/docs/android/#android-market-tracking get the referrer from the intent and take it apart to get the different parameters

使用你可以在那里建立的链接:http://code.google.com/mobile/analytics/docs/android/#android-market-tracking从意图中获取引用并将其分解以获得不同的参数

referrer = intent.getStringExtra("referrer");
Map<String, String> params = Toolbox.getQueryMap(referrer);

P.S. You don't need to read to read the deviceid/IMEI to do this, as some apps do. You shouldn't want to spy out your users.

附注:你不需要阅读deviceid/IMEI就能做到这一点,就像有些应用一样。你不应该想要监视你的用户。

#7


1  

Actually there could be any links like market://... or http://market... either work fine. Also it doesn't matter what kind of parameters will be in the referrer field. It works fine with any text in there.

实际上可以有任何类似市场的链接://…或http://market..。要么工作好。另外,在引用字段中包含哪些参数也无关紧要。它适用于任何文本。

The main issue that this event type "com.android.vending.INSTALL_REFERRER" doesn't send by broadcast. This event goes ONLY into the just installed application.

这个事件类型的主要问题是“com. android.售货机”。INSTALL_REFERRER“不会通过广播发送。此事件仅进入刚刚安装的应用程序。

UPD: And there only one way to test it - deploy your App into the Market and then install it on the phone.

UPD:只有一种测试方法——把你的应用程序部署到市场上,然后把它安装到手机上。

#8


0  

Use Google Play Referrer API (from 20 Nov 2017) very easily and securely as i answered here

使用谷歌播放引用API(从2017年11月20日开始)非常容易和安全,正如我在这里回答的