在视频群聊2.0休息SMS_RECEIVED的的BroadcastReceiver在我的应用程序启用短信支持 [英] Enabling SMS support in Hangouts 2.0 breaks the BroadcastReceiver of SMS_RECEIVED in my app

查看:157
本文介绍了在视频群聊2.0休息SMS_RECEIVED的的BroadcastReceiver在我的应用程序启用短信支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚收到更新的视频群聊2.0,安装并启用了短信→ 打开短信。现在运行的是Android 4.3下我的应用程序,是无法收到的短信更多,也就是我的BroadcastReceiver的 SMS_RECEIVED 不再调用。 : - (

I just received the update for Hangouts 2.0, installed it and enabled SMSTurn on SMS. Now my application, running under Android 4.3, is unable to receive SMS any more, i.e. my BroadcastReceiver for SMS_RECEIVED is no longer called. :-(

当我禁用在聊2.0开启短信,我的应用程序能够再次接收SMS_RECEIVED意图。

As soon as I disable Turn on SMS in Hangouts 2.0, my app is able to receive SMS_RECEIVED intents again.

此外,该广播接收器被登记在清单这样

The Broadcast receiver is registered in the Manifest like this

AndroidManifest.xml中

…
<receiver android:name=".SMSReceiver" >
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>
…

SMSReceiver.java

public class SMSReceiver extends BroadcastReceiver {

    private static final Log LOG = Log.getLog();

    @Override
    public void onReceive(Context context, Intent intent) {
            LOG.d("onReceive");
            …
    }
}

我已经试图改变接收机INT_MAX或999,它是尽可能高的优先级的意图过滤器文档的,但没有成功。 我知道 SMS_RECEIVED 意图是送有序和高优先级的应用程序有能力中止播出。 1 但似乎不太可能,聊2.0注册 SMS_RECEIVED 接收器,具有高优先级,并呼吁<一href="http://developer.android.com/reference/android/content/BroadcastReceiver.html#abortBroadcast%28%29"><$c$c>abortBroadcast(),因此$ P $接收的意图pventing任何其他应用程序。

I already tried to change the priority of the receiver to INT_MAX or 999, which is the highest possible priority as of the intent-filter documentation, but without success. I know that SMS_RECEIVED intents are send ordered and that high priority apps have the ability to abort the broadcast.1 But it seems unlikely that Hangouts 2.0 is registering the SMS_RECEIVED receiver with a high priority and calling abortBroadcast(), therefore preventing any other apps from receiving the intent.

<打击>什么进一步搞糊涂了,是我的小卵石仍然能够接收短信,甚至与视频群聊2.0的默认短信应用程序。我不知道什么小卵石做不同?我只注意到我的卵石传入的短信通知是新的短信由卵石应用程序接收的不再通知,而是是有致新环聊消息的通知常去玩的地方接收传入的短信。因此,卵石应用程序也无法接收传入的短信与 SMS_RECEIVED

What further confused me, is that my Pebble is still able to receive SMS, even with Hangouts 2.0 as default SMS app. I wonder what Pebble does different? I just noticed that the incoming SMS notification on my Pebble are no longer notifications for new SMS that are received by the Pebble app, but instead are "new Hangout message" notifications that are caused by hangouts receiving the incoming SMS. So the Pebble app is also not able to receive incoming text messages with SMS_RECEIVED.

在一个侧面说明并没有真正涉及到这个问题,因为我仍然在Android 4.3(但我的应用程序的目标SDK 19级,Android 4.4系统的情况下,它事项)有关的 http://android-developers.blogspot.de/2013/10/getting-your-sms-apps-ready-for-kitkat.html">new短信API,说,什么都不会改变应用程序只使用SMS_RECEIVED不要试图写短信SMS提供。

On a side note and not really related to this issue, because I am still on Android 4.3 (but my app targets SDK level 19, Android 4.4 in case it matters) Google's Android Developers Blog post about the new SMS API in Kitkat, said that nothing would change for apps using just SMS_RECEIVED and don't try to write the SMS to the SMS Provider.

1 我始终认为,SMS_RECEIVED广播是可中止。但是,的Andr​​oid 4.4 API的网站说不同的东西:当有新的短信息到达的...侦听该SMS_RECEIVED_ACTION广播,这是一个的非可中止的的广播...

1 I always believed that the SMS_RECEIVED broadcast is abortable. But the Android 4.4 APIs site says something different: "…when a new SMS arrives by listening for the SMS_RECEIVED_ACTION broadcast, which is a non-abortable broadcast…"

推荐答案

固定它。

第一个问题是,你可以在我的问题的修订版2看,我把优先级动作中的属性元素,当它实际上属于进意图过滤器元素。因此,优先级没有工作。

The first problem was that, as you can see in revision 2 of my question, I put the priority attribute within the action element, when it actually belongs into the intent-filter element. So the priority didn't work.

虽然仍定位API 19日,我做了视频群聊短信的一些经验和启用不同的优先级。

While still targeting API 19, I did some experiences with Hangouts SMS enabled and different priorities.

  • 在没有优先级设置→BroadcastReceiver的不接受 SMS_RECEIVED 意图
  • 优先级500→BroadcastReceiver的确实获得 SMS_RECEIVED 意图
  • 优先级999 1 →BroadcastReceiver的确实获得 SMS_RECEIVED 意图
  • No priority set → BroadcastReceiver doesn't receive SMS_RECEIVED intent
  • Priority 500 → BroadcastReceiver does receive SMS_RECEIVED intent
  • Priority 9991 → BroadcastReceiver does receive SMS_RECEIVED intent

这样看来,你需要有以获得与视频群聊短信的意图启用优先级的最小值。我没有刻意去平分可能的最低值。 ;)我将与999,因为我看不出有任何理由要得到更低的,因为我的应用程序不会对接收的短信只是一些简单的检查,并没有进一步对其进行处理。但是,要真正有所作为,作为广播是非可中止。

So it seems that you need to have a minimum value for priority in order to get the intent with Hangouts SMS enabled. I didn't bother to bisect the lowest possible value. ;) I am going with 999 as I don't see any reason to get lower because my app does just some quick checks on the received sms and does not further process it. But it should really make a difference, as the broadcast is non-abortable.

1 <一个href="http://stackoverflow.com/questions/6550989/what-is-the-integer-value-that-gives-a-broadcast-receiver-highest-priority">The最大值

这篇关于在视频群聊2.0休息SMS_RECEIVED的的BroadcastReceiver在我的应用程序启用短信支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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