我想将我的短信应用设为默认值。为此,我遵循this tutorial并修改了xml文件,如下所示:
<manifest>
...
<application>
<!-- BroadcastReceiver that listens for incoming SMS messages -->
<receiver android:name=".SmsReceiver"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_DELIVER" />
</intent-filter>
</receiver>
<!-- BroadcastReceiver that listens for incoming MMS messages -->
<receiver android:name=".MmsReceiver"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<!-- Activity that allows the user to send new SMS/MMS messages -->
<activity android:name=".ComposeSmsActivity" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</activity>
<!-- Service that delivers messages from the phone "quick response" -->
<service android:name=".HeadlessSmsSendService"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</service>
</application>
</manifest>
该应用现已设为默认值。但是当任何新的短信出现时,应用程序崩溃了。 logcat消息如下:
10-04 12:49:17.293: E/AndroidRuntime(10911): java.lang.RuntimeException: Unable to instantiate receiver com.commlink.smscheck.SmsReceiver: java.lang.ClassNotFoundException: Didn't find class "com.commlink.smscheck.SmsReceiver" on path: DexPathList[[zip file "/data/app/com.commlink.smscheck-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.commlink.smscheck-2, /vendor/lib, /system/lib]]
10-04 12:49:17.293: E/AndroidRuntime(10911): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2581)
10-04 12:49:17.293: E/AndroidRuntime(10911): at android.app.ActivityThread.access$1700(ActivityThread.java:151)
10-04 12:49:17.293: E/AndroidRuntime(10911): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1418)
10-04 12:49:17.293: E/AndroidRuntime(10911): at android.os.Handler.dispatchMessage(Handler.java:110)
10-04 12:49:17.293: E/AndroidRuntime(10911): at android.os.Looper.loop(Looper.java:193)
10-04 12:49:17.293: E/AndroidRuntime(10911): at android.app.ActivityThread.main(ActivityThread.java:5330)
10-04 12:49:17.293: E/AndroidRuntime(10911): at java.lang.reflect.Method.invokeNative(Native Method)
10-04 12:49:17.293: E/AndroidRuntime(10911): at java.lang.reflect.Method.invoke(Method.java:515)
10-04 12:49:17.293: E/AndroidRuntime(10911): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
10-04 12:49:17.293: E/AndroidRuntime(10911): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
10-04 12:49:17.293: E/AndroidRuntime(10911): at dalvik.system.NativeStart.main(Native Method)
10-04 12:49:17.293: E/AndroidRuntime(10911): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.commlink.smscheck.SmsReceiver" on path: DexPathList[[zip file "/data/app/com.commlink.smscheck-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.commlink.smscheck-2, /vendor/lib, /system/lib]]
10-04 12:49:17.293: E/AndroidRuntime(10911): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
10-04 12:49:17.293: E/AndroidRuntime(10911): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
10-04 12:49:17.293: E/AndroidRuntime(10911): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
10-04 12:49:17.293: E/AndroidRuntime(10911): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2576)
10-04 12:49:17.293: E/AndroidRuntime(10911): ... 10 more
错误在哪里?我怎么解决这个问题?