我正在开发建议应用程序的应用程序。如果用户使用我的应用成功安装了应用,那么他会在我的应用中获得奖励。我正在获取有关接收器的“com.android.vending.INSTALL_REFERRER”操作的信息,它提供了这个但没有成功......
所以请帮助我获得一些完整的例子或其他建议......
这是我的代码...
按钮点击事件
btnInstallApp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent goToMarket = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse("market://details?id=com.idea.backup.smscontacts&referrer=tecksky"));
startActivity(goToMarket);
}
});
清单.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tecksky.referrerdemo">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".receiver.ReferrerCatcher"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"></action>
</intent-filter>
</receiver>
</application>
</manifest>
ReferrerCatcher.java
public class ReferrerCatcher extends BroadcastReceiver {
private static String referrer = "";
@Override
public void onReceive(Context context, Intent intent) {
referrer = "";
Bundle extras = intent.getExtras();
if (extras != null) {
referrer = extras.getString("referrer");
}
Log.e("REFERRER : ", referrer);
}
}