Ric*_*ier 5 android android-intent android-3.0-honeycomb android-4.0-ice-cream-sandwich
我有一个BackgroundReceiver设置来接收android.intent.action.USER_PRESENT清单文件中的:
<receiver android:name="com.demo.MyBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
我的重写onReceive(Context, Intent)方法很简单:
@Override
public void onReceive(Context context, Intent intent)
{
if (intent != null)
{
if (Intent.ACTION_USER_PRESENT.equals(intent.getAction())
{
// wrapper for Log.d(String, String)
Dbug.log("MyBroadcastReceiver: [" + intent.getAction() + "]");
// this calls a service
serviceExample(context, intent);
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题:
ubuntudroid对此答案(仅带有服务的Android应用程序)有一条评论,说您需要至少启动一次活动才能正确接收所需的意图。
显然是在Android 3.0中引入的。
我还没有测试这个理论,但它可以解释你所看到的。
| 归档时间: |
|
| 查看次数: |
4260 次 |
| 最近记录: |