我已經設置了接收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