如何使用ACTION_PACKAGE_FIRST_LAUNCH意图过滤器来启动应用程序? [英] how to use ACTION_PACKAGE_FIRST_LAUNCH intent-filter to start application?
本文介绍了如何使用ACTION_PACKAGE_FIRST_LAUNCH意图过滤器来启动应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用意向过滤ACTION_PACKAGE_FIRST_LAUNCH使应用程序做一些任务时,它首次推出,但它没有被抓获的广播接收器 我的清单
I am trying to use the intent-filter ACTION_PACKAGE_FIRST_LAUNCH to make the application do some tasks when it first launched, however it not being captured by the broadcast receiver my Manifest
<receiver android:name=".reminder.ReminderActionReceiver" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_FIRST_LAUNCH" />
<action android:name="android.intent.action.PACKAGE_DATA_CLEARED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
这是我的广播接收器实施
this my broadcast receiver implementation
this.context = context;
String mAction = intent.getAction();
Log.i("r", mAction);
if (mAction == Intent.ACTION_PACKAGE_DATA_CLEARED) {
} else if (mAction == Intent.ACTION_PACKAGE_FIRST_LAUNCH) {
}
我
如何才能让它启动,当应用程序首次启动?
How can i make it start when the app first launched?
推荐答案
对不起除了boot_completed那些意图只发送到Play商店。但它是比较简单的做你的需要,否则。相反,使用共享preferences,像例如:
Sorry those intents except for boot_completed are only sent to the play store. But it is relatively simple to do what you need otherwise. Instead use SharedPreferences, like example:
public static final String KEY_PREFS_FIRST_LAUNCH = "first_launch";
// ...
SharedPreferences prefs = SharedPreferences.getDefaultSharedPreferences(this);
if(prefs.getBoolean(KEY_PREFS_FIRST_LAUNCH, true))
{
//first launch
prefs.edit().putBoolean(KEY_PREFS_FIRST_LAUNCH,false).commit();
}
这篇关于如何使用ACTION_PACKAGE_FIRST_LAUNCH意图过滤器来启动应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文