短信监听器做一些应用程序强制关闭 [英] SMS listener make some application force close

查看:143
本文介绍了短信监听器做一些应用程序强制关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的那一刻短信广播接收机。我也用GoSMS在我的手机上。

I'm creating at the moment a SMS Broadcast Receiver. I also use GoSMS in my phone.

的问题是:如果我不设置的android:优先或设定值小于 2147483647 (这是GoSms的优先级)

The problems is: if i dont set android:priority or set value less than 2147483647 (this is GoSms's priority)

我的接收器,我不能接收消息。

for my receiver, i cannot receive the message.

当我设置的android:优先=2147483647,我的应用程序可以接收该消息,但在我的手机某些应用已强制关闭:

When i set android:priority ="2147483647", my app can receive the message but, some application in my phone have been force close:

08-01 17:52:47.775: E/AndroidRuntime(3501): FATAL EXCEPTION: main
08-01 17:52:47.775: E/AndroidRuntime(3501): java.lang.RuntimeException: Unable to start service com.android.exchange.SmsRelayService@414f47f8 with Intent { cmp=com.android.exchange/.SmsRelayService (has extras) }: java.lang.NullPointerException
08-01 17:52:47.775: E/AndroidRuntime(3501):     at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2388)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at android.app.ActivityThread.access$1900(ActivityThread.java:127)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1222)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at android.os.Looper.loop(Looper.java:137)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at android.app.ActivityThread.main(ActivityThread.java:4507)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at java.lang.reflect.Method.invokeNative(Native Method)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at java.lang.reflect.Method.invoke(Method.java:511)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at dalvik.system.NativeStart.main(Native Method)
08-01 17:52:47.775: E/AndroidRuntime(3501): Caused by: java.lang.NullPointerException
08-01 17:52:47.775: E/AndroidRuntime(3501):     at android.provider.Telephony$Sms$Intents.getMessagesFromIntent(Telephony.java:888)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at com.android.exchange.SmsRelayService.onStartCommand(SmsRelayService.java:69)
08-01 17:52:47.775: E/AndroidRuntime(3501):     at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2371)

这是我的code

public class SmsListener extends BroadcastReceiver{
 @Override
    public void onReceive(Context context, Intent intent) {

        if(intent.getAction().equals(Constants.SMS_RECEIVED_ACTION)){
        // Do some thing
        }
}
}

<receiver android:name=".widget.SmsListener" >
            <intent-filter android:priority="2147483647">
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>

我在银河S2,ICS

I am running in Galaxy S2, ICS

请帮助我

问候

推荐答案

如果你只需要接收短信和你不想放弃短信广播,你可以简单地允许其他应用程序,通过改变去接收广播短信加强版的应用程序设置。您可以指导用户这样做,如果他们使用的是GO短信。这样的:打开GO短信,点击菜单,然后点击设置,点击接收设置,然后取消选择禁用其他消息通知。

If you just need to receive the SMS and you don't want to abort the SMS broadcast, you can simply allow other apps to receive the broadcast by changing GO SMS pro's application settings. You can instruct users to do that if they are using GO SMS. Like this: "Open Go SMS, hit 'Menu' and click 'Settings', click on 'Receive Settings', then uncheck the 'Disable other message notifications."

但是,如果你需要中止播出,让我说,设置优先级等于2147483647并没有为我工作。底线是,这两个应用程序接收的广播和手机短信将实际收到。第一个应用安装的规则建议<一href=\"http://stackoverflow.com/questions/6600266/sup$p$pss-block-broastreceiver-in-another-app\">here (查看所选答案评论)和<一个href=\"http://stackoverflow.com/questions/6561297/sms-broadcastreceiver-not-called-when-go-sms-pro-installed\">here对我也没有工作。

But if you need to abort the broadcast, let me say that setting the priority equal to "2147483647" didn't work for me. The bottom line was that both applications received the broadcast and the SMS would actually receive. The first-app-installed rule suggested here (see the comments for the selected answer) and here didn't work for me either.

不过有人建议一片code的<一个href=\"http://stackoverflow.com/questions/8030777/android-provider-telephony-sms-received-not-working-on-my-device-htc-wildfire\">here ,显然你可以用它在设备上运行的接收器的列表,你最好考虑这一点。所以希望你能提醒一些接收器可能会干扰到自己设置的用户,这样你就不会得到一个明星带队伍从用户的应用程序不工作的评论。

However some one suggested a piece of code here that apparently you can get a list of receivers running on the device with it, you'd better look into that. So hopefully you can warn the user of some receiver that might interfere with yours, so you won't get one-star ranks with a "App doesn't work" comment from the users.

这篇关于短信监听器做一些应用程序强制关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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