gpt4 book ai didi

android - 无法在 BroadcastReceiver SMS 中实例化接收器

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:19:32 24 4
gpt4 key购买 nike

为什么我有这个错误:

ERROR/AndroidRuntime(854): Uncaught handler: thread main exiting due to uncaught exception
ERROR/AndroidRuntime(854): java.lang.RuntimeException: Unable to instantiate receiver com.android.GPS21.SmsReceiver: java.lang.ClassNotFoundException: com.android.GPS21.SmsReceiver in loader dalvik.system.PathClassLoader@43d02ef0
ERROR/AndroidRuntime(854): Caused by: java.lang.ClassNotFoundException: com.android.GPS21.SmsReceiver in loader dalvik.system.PathClassLoader@43d02ef0

这是我的 onReceive 事件:

public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.i(LOG_TAG, "Recieved a message");
if (intent.getAction().equals(ACTION)) {
// if(message starts with SMStretcher recognize BYTE)
StringBuilder sb = new StringBuilder();

// The SMS-Messages are 'hiding' within the extras of the Intent.
Bundle bundle = intent.getExtras();
if (bundle != null) {

// Get all messages contained in the Intent
// Telephony.Sms.Intents.getMessagesFromIntent(intent) does not
// work anymore hence the below changes

Object[] pduObj = (Object[]) bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pduObj.length];
for (int i = 0; i < pduObj.length; i++)
messages[i] = SmsMessage.createFromPdu((byte[]) pduObj[i]);
// Feed the StringBuilder with all Messages found.
for (SmsMessage currentMessage : messages) {
sb.append("SMS Received From: ");
// Sender-Number
sb.append(currentMessage.getDisplayOriginatingAddress());
sb.append("\nMessage : ");
// Actual Message-Content
sb.append(currentMessage.getDisplayMessageBody());
}
}
// Logger Debug-Output
Log.i(LOG_TAG, "[SMSApp] onReceive: " + sb);

// Show the Notification containing the Message.
Toast.makeText(context, sb.toString(), Toast.LENGTH_LONG).show();
}

正在调试 onReceive() 错误。

我只是让 BroadcastReceiver 接收短信并在通知 Toast 中显示..

然后我尝试从 DDMS 发送短信,但出现该错误。

最佳答案

您的 list 声明您有一个名为 com.android.GPS21.SmsReceiver 的类,但 Android 无法找到它。

关于android - 无法在 BroadcastReceiver SMS 中实例化接收器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4619049/

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