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

android – 无法在BroadcastReceiver SMS中实例化接收器,第1张

概述为什么我有这个错误: ERROR/AndroidRuntime(854): Uncaught handler: thread main exiting due to uncaught exceptionERROR/AndroidRuntime(854): java.lang.RuntimeException: Unable to instantiate receiver com.android. 为什么我有这个错误:
ERROR/AndroIDRuntime(854): Uncaught handler: thread main exiting due to uncaught exceptionERROR/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@43d02ef0ERROR/AndroIDRuntime(854): Caused by: java.lang.classNotFoundException: com.androID.GPS21.SmsReceiver in loader dalvik.system.PathClassLoader@43d02ef0@H_502_3@  

这是我的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();  }@H_502_3@  

在调试中,onReceive()是错误的.

我只是让broadcastReceiver收到短信,并通知Toast ..

我尝试从DDMS发送短信,出现错误.

解决方法 你的清单声称你有一个名为com.androID.GPS21.SmsReceiver的类,AndroID找不到它. 总结

以上是内存溢出为你收集整理的android – 无法在BroadcastReceiver SMS中实例化接收器全部内容,希望文章能够帮你解决android – 无法在BroadcastReceiver SMS中实例化接收器所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1131613.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存