Intent.ACTION_USER_PRESENT not received on HoneyComb or ICS (Samsung) devices

对着背影说爱祢 提交于 2019-12-18 08:29:28

问题


I have a BackgroundReceiver set up to receive the android.intent.action.USER_PRESENT in the manifest file as per:

    <receiver android:name="com.demo.MyBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>

My overridden onReceive(Context, Intent) method is very simple:

@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);
        }
    }
}

  • This tested perfectly on 2.1, 2.2 & 2.3 devices (HTC Desire, HTC WildFire, Motorola Razr).
  • This does not seem to work on HoneyComb (Samsung Galaxy Tab 10.1) or ICS (Samsung Galaxy Nexus) devices.
  • As per this bug (USER_PRESENT never fires on honeycomb and ICS when keyguard is disabled), I set the keyguard on the failing devices. It did not help.

Questions:

  1. Is there some trick to using these intent actions on Android 3.x & 4.x?
  2. Perhaps this is a known Samsung issue?
  3. Or perhaps there is some device setting I have neglected on these devices?

回答1:


There is a comment by ubuntudroid on this answer (android app with service only) that says you need to start your activity at least once before it will correctly receive the required intents.

Apparently introduced in Android 3.0.

I have not tested this theory yet, but it would explain what you are seeing.



来源:https://stackoverflow.com/questions/10329810/intent-action-user-present-not-received-on-honeycomb-or-ics-samsung-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!