在上传到Google Play之前,当我尝试使用以下脚本测试应用程序时,它的工作正常,我正在获得引用字符串.
adb shell am broadcast -a com.androID.vending.INSTALL_REFERRER -n <my.myPackage>/.<path.up.until.my.CustombroadcastReceiver> --es "referrer" "utm_source%3Dentity%26utm_medium%3Dsocial%26utm_campaign%3DWo_referrer%26referrerID%3D173%26entity%3Dfacebook%26email%3DmIDeeshp%40email.com"
运行此代码后,我将根据引荐字符串对引用字符串和我的服务器进行更新.但是当我将此应用程序部署到Google Play时,我没有从Google播放中获取任何推荐字符串.我正在使用Google Analytics(分析)V2进行分析跟踪和引荐跟踪.
下面是我的定制broadcastReceiver.
public class installreferrerReceiver extends broadcastReceiver {private static final String TAG = "installreferrerReceiver";@OverrIDepublic voID onReceive(Context context,Intent intent) { HashMap<String,String> values = new HashMap<String,String>(); try { if (intent.hasExtra("referrer")) { Toast.makeText(context,"InsIDe app refferal",5000).show(); String url = intent.getStringExtra("referrer"); final String referrer = URLDecoder.decode(url,"UTF-8"); String referrers[] = referrer.split("&"); int i = 0; for (String referrerValue : referrers) { String keyvalue[] = referrerValue.split("="); values.put(URLDecoder.decode(keyvalue[0],"UTF-8"),URLDecoder.decode(keyvalue[1],"UTF-8")); Log.i("" + i,keyvalue[0] + "=" + keyvalue[1]); } new AsyncTask<String,String,JsONObject>() { @OverrIDe protected voID onPreExecute() { super.onPreExecute(); } @OverrIDe protected JsONObject doInBackground(String... params) { // Todo auto-generated method stub String referrerUrl = "MyserverUrl?action=storerefer&" + referrer; Log.i("purl address",referrerUrl); JsONObject Json = RestJsonClIEnt.connect(referrerUrl); return Json; } @OverrIDe protected voID onPostExecute(JsONObject result) { // Todo auto-generated method stub try { if (result == null) { Log.i("Json null","12"); } else { String status,error; status = result.getString("status"); error = result.getString("error"); if (status.equals("success")) { Log.i("referrer","referrer status success"); } if (status.equals("failure")) { Log.i("referrer","referrer status failure"); } } } catch (JsONException e) { e.printstacktrace(); } catch (Exception e) { e.printstacktrace(); } super.onPostExecute(result); } }.execute(); } } catch (Exception e) { }}
AndroIDManifest.xml中
<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID"package="my.package.name"androID:versionCode="4"androID:versionname="1.2.1" ><supports-screens androID:anyDensity="true" androID:largeScreens="true" androID:normalScreens="true" androID:resizeable="true" androID:smallScreens="true" /><uses-sdk androID:minSdkVersion="8" androID:targetSdkVersion="19" /><uses-feature androID:name="androID.harDWare.telephony" androID:required="false" /><uses-feature androID:name="androID.harDWare.touchscreen" androID:required="false" /><uses-feature androID:glEsversion="0x00020000" androID:required="true" /><uses-permission androID:name="androID.permission.INTERNET" /><uses-permission androID:name="androID.permission.ACCESS_NETWORK_STATE" /><uses-permission androID:name="androID.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission androID:name="androID.permission.RECEIVE_BOOT_COMPLETED" /><uses-permission androID:name="androID.permission.READ_CONTACTS" /><uses-permission androID:name="androID.permission.READ_PHONE_STATE" /><uses-permission androID:name="androID.permission.RECEIVE_SMS" /><uses-permission androID:name="androID.permission.SEND_SMS" /><uses-permission androID:name="androID.permission.GET_ACCOUNTS" /><uses-permission androID:name="androID.permission.WAKE_LOCK" /><uses-permission androID:name="my.package.name.permission.C2D_MESSAGE" /><uses-permission androID:name="com.Google.androID.c2dm.permission.RECEIVE" /><uses-permission androID:name="androID.permission.ACCESS_NETWORK_STATE" /><uses-permission androID:name="androID.permission.VIBRATE" /><uses-permission androID:name="androID.permission.RECEIVE_SMS" /><permission androID:name="my.package.name.permission.C2D_MESSAGE" androID:protectionLevel="signature" /><application androID:allowBackup="true" androID:icon="@drawable/ic_launcher" androID:label="@string/app_name" androID:theme="@androID:style/theme.Black.NoTitlebar" > <activity androID:name="my.package.name.Splash" androID:configChanges="orIEntation|keyboardHIDden|screenSize" androID:label="@string/app_name" androID:windowsoftinputMode="stateHIDden" > <intent-filter> <action androID:name="androID.intent.action.MAIN" /> <category androID:name="androID.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver androID:name="my.package.name.installreferrerReceiver" androID:exported="true" > <intent-filter> <action androID:name="com.androID.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> <receiver androID:name="com.Google.androID.gcm.GCMbroadcastReceiver" androID:permission="com.Google.androID.c2dm.permission.SEND" > <intent-filter> <action androID:name="com.Google.androID.c2dm.intent.RECEIVE" /> <action androID:name="com.Google.androID.c2dm.intent.REGISTRATION" /> <category androID:name="my.package.name" /> </intent-filter> </receiver> <service androID:name="my.package.name.GCMIntentService" /></application>
如何从Google Play获取推荐字串?
解决方法 你可以写这个简单的接收器:public class DetectInstall extends broadcastReceiver{private String referrerID;@OverrIDepublic voID onReceive(Context context,Intent intent) { if ((null != intent) && (intent.getAction().equals("com.androID.vending.INSTALL_REFERRER"))) { Log.e("Message","App is getting installed first time.."); referrerID = intent.getStringExtra("referrer"); }}
}
然后在清单中添加接收器标签内的应用程序,如下所示:
<application androID:harDWareAccelerated="true" androID:icon="@drawable/ic_bmg" androID:label="@string/app_name" androID:screenorIEntation="portrait" androID:theme="@style/Apptheme" > <receiver androID:name=".DetectInstall" androID:exported="true" > <intent-filter> <action androID:name="com.androID.vending.INSTALL_REFERRER" /> </intent-filter> </receiver>
那么您需要将referrer参数发送到Google playstore URL,就像这样:
https://play.google.com/store/apps/details?id=you.package.name&hl=en&referrer=you将首次安装应用程序
引荐来源字段是必需的,无论您在引荐来源网址中传递什么字符串,您都可以在广播接收者中获取
总结以上是内存溢出为你收集整理的java – Android引荐跟踪不能与Google Play一起使用全部内容,希望文章能够帮你解决java – Android引荐跟踪不能与Google Play一起使用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)