拦截来袭的短信三星 - Android电子 [英] Intercept incoming SMS samsung - Android

查看:129
本文介绍了拦截来袭的短信三星 - Android电子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java中使用以下code拦截短信

I'm intercepting SMS using the following code in Java

public class SmsReceiver extends BroadcastReceiver {

     @Override
     public void onReceive(Context context, Intent intent) {

            Bundle extras = intent.getExtras();
            if (extras == null)
                   return;


            Object[] pdus = (Object[]) extras.get("pdus");
            for (int i = 0; i < pdus.length; i++) {
                   SmsMessage SMessage = SmsMessage.createFromPdu((byte[]) pdus[i]);
                   String sender = SMessage.getOriginatingAddress();
                   String body = SMessage.getMessageBody().toString();
                    Log.i("TAG", body);
                   //... do whatever with the message here


            }
     }
}

与在manifest.xml下面的接收器

with the following receiver in the Manifest.xml

</receiver>
<receiver android:name="com.example.test.SmsReceiver" >
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>

它的工作罚款的Nexus 5,但它不是三星,任何人都知道如何让它在三星工作

It's working fine with Nexus 5, but it's not in Samsung, anyone knows how to make it work in Samsung

推荐答案

pre-奇巧短信广播可能被截获,甚至中止,但聊会仍然处理消息。看到这个帖子:

Pre-KitKat SMS broadcasts could be intercepted or even aborted, but Hangouts will still process the message. See this post:

<一个href=\"http://stackoverflow.com/questions/6600266/sup$p$pss-block-broastreceiver-in-another-app/6877010#6877010\">Sup$p$pss /砌块BroastReceiver在另一个应用

和这样的:

<一个href=\"http://stackoverflow.com/questions/20021492/enabling-sms-support-in-hangouts-2-0-breaks-the-broadcastreceiver-of-sms-receive\">Enabling在Hangouts 2.0休息短信支持S​​MS_RECEIVED在我的应用程序中的广播接收器

环聊注册了AbortSmsRecevier具有优先级3,所以上面的设置3你的接收机应优先解决您的问题,并拦截。不过,如果你想要得到的消息第一,然后999应该这样做。但是,请注意,这不是因为反垃圾邮件应用程序的理想,例如,可能需要您的应用程序之前处理该消息确实,这取决于你的应用程序一样。 (这个问题 - 应用的战斗为最高优先级的是Android与奇巧,变化是好是原因更糟......)

Hangouts has registered their AbortSmsRecevier with a priority "3" so setting your receiver priority above "3" should solve your problem and intercept it. However, if you trying to get the message "first" then "999" should do that. However, be aware that this is not ideal since anti-spam apps, for example, may need to process the message before your apps does, depending on what you app does. (This problem - apps "fighting for highest priority" is the reason Android changed with KitKat, for better or for worse...)

这是从谷歌通话/巴贝尔清单中的摘录:

This is the excerpt from the Google Talk / Babel manifest:

    <receiver android:name="com.google.android.apps.babel.sms.AbortSmsReceiver" android:permission="android.permission.BROADCAST_SMS" android:enabled="false">
        <intent-filter android:priority="3">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
    </receiver>

如果您要中止的消息,那么你就会有问题。处理消息的视频群聊短信接收器设置为 Integer.MAX_VALUE的,但中止消息时,接收者是我刚刚张贴的人。

If you are trying to abort the message, then you will have problems. The Hangouts SMS receiver that processes the message is set to Integer.MAX_VALUE, but the receiver that aborts the message is the one I just posted.

下面是其他接收器:

    <receiver android:name="com.google.android.apps.babel.sms.SmsReceiver" android:permission="android.permission.BROADCAST_SMS" android:enabled="false">
        <intent-filter android:priority="2147483647">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
    </receiver>

请注意:在999或更低优先-999是系统级 - 但是,文档指出非系统应用程序要求高于此优先级将有UN predictable的行为。这绝对是我见过的 - 应用程序将无法predictably或可靠的拍的其他应用程序在该水平之上(根据设备的安装顺序,重新启动等)

Note: priorities over "999" or below "-999" are "system level" - however, the documentation states that non-system apps requesting a priority above this will have "unpredictable" behavior. Which is definitely what I've seen - apps will not predictably or reliable "beat" other apps above that level (depending on the device, install order, rebooting, etc.).

这篇关于拦截来袭的短信三星 - Android电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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