Intent.ACTION_USER_ preSENT在蜂窝或ICS(Samsung)的设备没有收到 [英] Intent.ACTION_USER_PRESENT not received on HoneyComb or ICS (Samsung) devices

查看:146
本文介绍了Intent.ACTION_USER_ preSENT在蜂窝或ICS(Samsung)的设备没有收到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 BackgroundReceiver 设置为接收 android.intent.action.USER_ preSENT 的清单文件按:

 <接收器的Andr​​oid版本:NAME =com.demo.MyBroadcastReceiver>
        <意向滤光器>
            <作用机器人:名称=android.intent.action.USER_ preSENT/>
        &所述; /意图滤光器>
    < /接收器>
 

我重写的onReceive(上下文,意图)的方法很简单:

  @覆盖
公共无效的onReceive(上下文的背景下,意图意图)
{
    如果(意向!= NULL)
    {

        如果(Intent.ACTION_USER_ preSENT.equals(intent.getAction())
        {
            //包装Log.d(字符串,字符串)
            Dbug.log(MyBroadcastReceiver:[+ intent.getAction()+]);

            //这个调用服务
            serviceExample(背景下,意图);
        }
    }
}
 


  • 这完全测试的2.1,2.2和放大器; 2.3设备(HTC渴望,HTC野火,摩托罗拉RAZR)。
  • 这似乎并没有工作在蜂窝(三星Galaxy Tab 10.1)或ICS(三星Galaxy Nexus的)设备。
  • 按照这个bug( USER_ preSENT永远大火在蜂窝和ICS时,键盘锁定禁用),我设置的故障设备的键盘锁。它并没有帮助。

问题:

  1. 有一些技巧,使用在Android 3.X及放这些意图的行动; 4.x的?
  2. 也许这是一个已知的问题,三星?
  3. 或者,也许有一些设备的设置我都忽视了这些设备?
解决方案

目前在这个答案评论由 ubuntudroid 与服务只的Andr​​oid应用程序)说,你需要开始你的活动至少一次,然后才能正确地接收到所需的意图

显然,在的Andr​​oid 3.0推出。

我没有测试过这种理论还没有,但它可以解释你所看到的。

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


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?

解决方案

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.

这篇关于Intent.ACTION_USER_ preSENT在蜂窝或ICS(Samsung)的设备没有收到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆