我想为我的应用程序使用安装引荐来源网址。我尝试了谷歌教程。然后我发现了这个。 我用了: https://github.com/coderminion/AndroidReferrer
一切都很好。尝试使用模拟器时。
但是在发布goole之后,请继续留店。我正在尝试真实的测试。有时引荐即将到来,但有时却为空。
我尝试了Google Play教程 https://developer.android.com/google/play/installreferrer
公共类MainActivity扩展了AppCompatActivity {
private final BroadcastReceiver mUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
.setTitle("Coderminion.com Android Referer : ")
.setMessage("Recieved Data is : "+getReferer(MainActivity.this))
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
builder.show();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
.setTitle("Coderminion.com Android Referer : ")
.setMessage("Recieved Data is : "+getReferer(MainActivity.this))
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
builder.show();
}
});
}
@Override
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mUpdateReceiver);
super.onPause();
}
@Override
protected void onResume() {
LocalBroadcastManager.getInstance(this).registerReceiver(mUpdateReceiver, new IntentFilter(RefererDataReciever.ACTION_UPDATE_DATA));
super.onResume();
}
public static String getReferer(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
if (!sp.contains(REFERRER_DATA)) {
return "Didn't got any referrer follow instructions :)";
}
return sp.getString(REFERRER_DATA, null);
}
}
问题是一样的,在发布之后有时引荐来源即将到来。有时它不会来。