I am trying to create an app that receives SMS messages and if it has a specific prefix it uses the information in it then deletes it. I have it where it shows no errors and seems like it would run but when ran it force closes. Here is my code:
SMSReceiver.java: package com.TWP.Project.IES; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.SmsMessage; import android.widget.Toast; import com.TWP.Project.IES.DenCryption; public class SMSReceiver extends BroadcastReceiver { DenCryption decrypter = new DenCryption(); @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); Object messages[] = (Object[]) bundle.get("pdus"); SmsMessage smsMessage[] = new SmsMessage[messages.length]; for (int n = 0; n < messages.length; n++) { smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]); } if(smsMessage[0].getMessageBody().startsWith("*DenCryption3*:")) { String msg = smsMessage[0].getMessageBody().replace("*DenCryption3*:", ""); msg = decrypter.decrypt(msg); Toast toast = Toast.makeText(context, msg, Toast.LENGTH_LONG); toast.show(); abortBroadcast(); } } } AndroidManifest.xml: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.TWP.Project.IES" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" /> <uses-permission android:name="android.permission.RECEIVE_SMS"/> <uses-permission android:name="android.permission.WRITE_SMS"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <receiver android:name="com.TWP.Project.TDC.SMSReceiver" android:enabled="true"> <intent-filter android:priority="2147483647"> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> </application> </manifest> I am attaching the log from LogCat. I can't seem to find what my problem is. -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
04-01 17:56:40.417: D/AndroidRuntime(581): Shutting down VM 04-01 17:56:40.417: W/dalvikvm(581): threadid=1: thread exiting with uncaught exception (group=0x40015560) 04-01 17:56:40.427: E/AndroidRuntime(581): FATAL EXCEPTION: main 04-01 17:56:40.427: E/AndroidRuntime(581): java.lang.RuntimeException: Unable to instantiate receiver com.TWP.Project.TDC.SMSReceiver: java.lang.ClassNotFoundException: com.TWP.Project.TDC.SMSReceiver in loader dalvik.system.PathClassLoader[/data/app/com.TWP.Project.IES-1.apk] 04-01 17:56:40.427: E/AndroidRuntime(581): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1773) 04-01 17:56:40.427: E/AndroidRuntime(581): at android.app.ActivityThread.access$2400(ActivityThread.java:117) 04-01 17:56:40.427: E/AndroidRuntime(581): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981) 04-01 17:56:40.427: E/AndroidRuntime(581): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 17:56:40.427: E/AndroidRuntime(581): at android.os.Looper.loop(Looper.java:123) 04-01 17:56:40.427: E/AndroidRuntime(581): at android.app.ActivityThread.main(ActivityThread.java:3683) 04-01 17:56:40.427: E/AndroidRuntime(581): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 17:56:40.427: E/AndroidRuntime(581): at java.lang.reflect.Method.invoke(Method.java:507) 04-01 17:56:40.427: E/AndroidRuntime(581): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-01 17:56:40.427: E/AndroidRuntime(581): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-01 17:56:40.427: E/AndroidRuntime(581): at dalvik.system.NativeStart.main(Native Method) 04-01 17:56:40.427: E/AndroidRuntime(581): Caused by: java.lang.ClassNotFoundException: com.TWP.Project.TDC.SMSReceiver in loader dalvik.system.PathClassLoader[/data/app/com.TWP.Project.IES-1.apk] 04-01 17:56:40.427: E/AndroidRuntime(581): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 04-01 17:56:40.427: E/AndroidRuntime(581): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 04-01 17:56:40.427: E/AndroidRuntime(581): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 04-01 17:56:40.427: E/AndroidRuntime(581): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1764) 04-01 17:56:40.427: E/AndroidRuntime(581): ... 10 more