次のように、マニフェスト ファイルで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>
私のオーバーライドされた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、Motorola Razr) で完全にテストされました。
- これは、HoneyComb (Samsung Galaxy Tab 10.1) または ICS (Samsung Galaxy Nexus) デバイスでは機能しないようです。
- このバグ (キーガードが無効になっていると、ハニカムと ICS で USER_PRESENT が起動しない) に従って、失敗したデバイスにキーガードを設定しました。役に立ちませんでした。
質問:
- Android 3.x & 4.x でこれらのインテント アクションを使用するためのトリックはありますか?
- おそらく、これは Samsung の既知の問題ですか?
- または、これらのデバイスで無視したデバイス設定があるのでしょうか?