gpt4 book ai didi

android - BroadcastReceiver 尝试在无序广播期间返回结果 - SMS 接收器

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:47:29 26 4
gpt4 key购买 nike

我知道有很多这样的帖子,但没有一个对我有帮助...

我的 list 声明:

        <receiver android:name="com.myapp.SMSReciever">
<intent-filter android:priority="99999999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

短信接收者.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 broadcast
09-10 16:27:30.369: E/BroadcastReceiver(25028): java.lang.RuntimeException: BroadcastReceiver trying to return result during a non-ordered broadcast
09-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.access$2400(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 的应用程序导致了这个错误。根据文档:

中止广播: 设置标志,指​​示此接收器应中止当前广播;仅适用于通过 Context.sendOrderedBroadcast 发送的广播。 - 请注意这一点。

而且应用程序似乎没有启动有序广播,因此抛出异常。

关于android - BroadcastReceiver 尝试在无序广播期间返回结果 - SMS 接收器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18722206/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com