简体   繁体   English

install_referrer如何工作

[英]How install_referrer works

i am trying to use install_referrer and have a question, my app only "catches" the referrer broadcast when its open or in the memory. 我正在尝试使用install_referrer并有一个问题,我的应用程序仅在打开或在内存中时“捕获”引荐来源广播。 but when you install an app from tha play store its not getting open nor on the memory, so how can i make my app catch the broadcast on installation if its not running on the backround? 但是,当您从Play商店安装应用时,它没有打开也不在内存中,所以如果我的应用未在后台运行,我该如何使我的应用在安装时捕获广播? thats my code: 那就是我的代码:

public class SDK_Referrer extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "entered onRecive");
    if (intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) {
        String referrer = intent.getStringExtra("referrer");

Thanks! 谢谢!

You need to add the receiver to your manifest, so your app knows you have something listening for the broadcast. 您需要将接收器添加到清单中,以便您的应用程序知道您正在收听广播。 Something like this: 像这样:

<receiver android:name="com.company.cool.SDK_Referrer" android:exported="true">
    <intent-filter>
      <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
  </receiver>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM