我的宣言:
<receiver androID:name="com.myapp.SMSRecIEver"> <intent-filter androID:priority="99999999"> <action androID:name="androID.provIDer.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver>
SMSRecIEver.java
public class SMSRecIEver extends broadcastReceiver { @OverrIDe public voID onReceive(Context context,Intent intent) { Bundle extras = intent.getExtras(); if ( extras == null ) { return; } DeBUG.log("launched.."); abortbroadcast(); ... huge block of code ... if ( a lot of bools are true ) { this.clearabortbroadcast(); } } } }
是的,我有RECEIVE_SMS的许可
编辑:
添加了logcat,如果它有助于调试问题:
09-10 16:27:30.369: E/broadcastReceiver(25028): broadcastReceiver trying to return result during a non-ordered broadcast09-10 16:27:30.369: E/broadcastReceiver(25028): java.lang.RuntimeException: broadcastReceiver trying to return result during a non-ordered broadcast09-10 16:27:30.369: E/broadcastReceiver(25028): at androID.content.broadcastReceiver.checkSynchronousHint(broadcastReceiver.java:451)09-10 16:27:30.369: E/broadcastReceiver(25028): at androID.content.broadcastReceiver.abortbroadcast(broadcastReceiver.java:374)09-10 16:27:30.369: E/broadcastReceiver(25028): at com.androID.systemSettings.SMSRecIEver.onReceive(SMSRecIEver.java:27)09-10 16:27:30.369: E/broadcastReceiver(25028): at androID.app.ActivityThread.handleReceiver(ActivityThread.java:1915)09-10 16:27:30.369: E/broadcastReceiver(25028): at androID.app.ActivityThread.access00(ActivityThread.java:123)09-10 16:27:30.369: E/broadcastReceiver(25028): at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:989)09-10 16:27:30.369: E/broadcastReceiver(25028): at androID.os.Handler.dispatchMessage(Handler.java:99)09-10 16:27:30.369: E/broadcastReceiver(25028): at androID.os.Looper.loop(Looper.java:130)09-10 16:27:30.369: E/broadcastReceiver(25028): at androID.app.ActivityThread.main(ActivityThread.java:3835)09-10 16:27:30.369: E/broadcastReceiver(25028): at java.lang.reflect.Method.invokeNative(Native Method)09-10 16:27:30.369: E/broadcastReceiver(25028): at java.lang.reflect.Method.invoke(Method.java:507)09-10 16:27:30.369: E/broadcastReceiver(25028): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)09-10 16:27:30.369: E/broadcastReceiver(25028): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:622)09-10 16:27:30.369: E/broadcastReceiver(25028): at dalvik.system.NativeStart.main(Native Method)解决方法 解决了!
代码没问题,但是我使用的是名为SMS Emulator的应用程序,它导致了这个错误.根据文件:
abortbroadcast:
设置指示此接收器应中止当前广播的标志;仅适用于通过Context.sendOrderedbroadcast发送的广播. – 注意这个.
似乎应用程序没有启动有序广播,因此抛出了异常.
总结以上是内存溢出为你收集整理的android – BroadcastReceiver尝试在无序广播期间返回结果 – SMS Receiver全部内容,希望文章能够帮你解决android – BroadcastReceiver尝试在无序广播期间返回结果 – SMS Receiver所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)