我已经设置了接收android.intent.action.USER_PRESENT
清单文件为每BackgroundReceiver
:Intent.ACTION_USER_PRESENT在蜂窝或ICS(Samsung)的设备没有收到
<receiver android:name="com.demo.MyBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
我重写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);
}
}
}
- 这完全测试了2.1,2.2 & 2。 3款设备(HTC Desire,HTC WildFire,摩托罗拉Razr)。
- 这似乎不适用于HoneyComb(Samsung Galaxy Tab 10.1)或ICS(Samsung Galaxy Nexus)设备。
- 根据此错误(USER_PRESENT never fires on honeycomb and ICS when keyguard is disabled),我在失败的设备上设置了键盘锁。它没有帮助。
问题:
- 有一些技巧,使用在Android 3.X & 4.x的这些意图的行动?
- 也许这是一个已知的三星问题?
- 或者我在这些设备上忽略了一些设备设置?
这个问题意味着它可以做到:[带上任务前面android.intent.action.USER_PRESENT](http://stackoverflow.com/questions/8750854/bring-task-to-front-on-android- intent-action-user-present) – 2012-05-21 15:07:14