我正在尝试注册一个广播接收器,它捕获Android从市场安装应用程序后启动的"com.android.vending.INSTALL_REFERRER"意图.
我在此处详细了解:http://code.google.com/mobile/analytics/docs/android/#referrals
但是,我无法使用Google Analytics,因此我创建了自己的解决方案.我在清单文件中添加了以下内容:
<receiver android:name="com.test.Receiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
并创建了一个基本的BroadcastReceiver类:
public class Receiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
String referrerString = extras.getString("referrer");
Log.w("TEST", "Referrer is: " + referrerString);
}
}
Run Code Online (Sandbox Code Playgroud)
然而,当安装应用程序时,接收器似乎没有捕获Intent(如果Intent甚至广播?)并且我没有记录输出.
我在某个地方出错了还是市场在安装应用程序时不再启动这些Intent?
我在我的片段中使用ShowCase View库.我展示了一个手势动画,应该重复,直到用户按下OK按钮.但只显示一次.
每次创建片段时都会显示展示,而不仅仅是一次.
我的代码看起来像这样:
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//get display size for slide over screen
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point p = new Point();
display.getSize(p);
if(!is_tablet()){
// ShowView Tutorial if on smartphone
ViewTarget target = new ViewTarget(getView());
ShowcaseView.ConfigOptions co = new ShowcaseView.ConfigOptions();
//can only dismiss by button click
co.hideOnClickOutside = false;
//show only once
co.shotType = ShowcaseView.TYPE_ONE_SHOT;
sv = ShowcaseView.insertShowcaseView(target, getActivity(),
R.string.showcase_detail_title, R.string.showcase_detail_message,co);
// remove circle
sv.setShowcaseIndicatorScale(0);
// set black background
sv.setBackgroundColor(getResources().getColor(R.color.black));
// make background a …Run Code Online (Sandbox Code Playgroud)