【发布时间】:2014-12-23 11:59:03
【问题描述】:
安装应用后,我在从 google play URL 传递 transaction_id 时遇到问题。
网址如下所示: https://play.google.com/store/apps/details?id=com.bouncing.mate.bouncer&transaction_id=12345
当使用此 url 安装应用程序时,我尝试从 INSTALL_REFERRER Intent 检索 transaction_id 值。为此,我在清单中声明了一个接收器:
<!-- The Google Play com.android.vending.INSTALL_REFERRER Intent is broadcast when an app is installed from the Google Play Store.
This broadcast receiver listens for that Intent, passing the data required for app install tracking. -->
<receiver
android:name=".data.tracking.AppInstallReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
我的接收器类如下所示:
public class AppInstallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.hasExtra("transaction_id")) {
// Intent has transaction id extra, start Service that will handle tracking
context.startService(AppInstallService.getIntent(context, intent.getStringExtra("transaction_id")));
}
}
}
问题是我认为我的服务从未启动过......我不确定“transaction_id”参数是否可以通过这种方式传递?到目前为止,在我看到的所有示例中,都使用了“引用者”键。 例如:
Bundle extras = intent.getExtras();
String referrerString = extras.getString("referrer");
服务已使用:
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER --es "transaction_id" "1234567" 它应该可以正常工作,但是在安装时收到意图是我无法测试的。
【问题讨论】:
标签: android android-intent google-play