我正在使用意圖發送短信與圖像的Android應用程序,但我收到異常ActivityNotFoundException
。 AndroidManifest.xml中發送短信時沒有發現活動異常
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shareviamms"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Java代碼我想在Android 4.2
:
Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setClassName("com.android.mms","com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/32X32.png"));
sendIntent.setType("image/png");
startActivity(sendIntent);
堆棧跟蹤
12-14 23:07:55.332: E/AndroidRuntime(11322): FATAL EXCEPTION: main
12-14 23:07:55.332: E/AndroidRuntime(11322): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.shareviamms/com.example.shareviamms.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.mms/com.android.mms.ui.ComposeMessageActivity}; have you declared this activity in your AndroidManifest.xml?
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2187)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.ActivityThread.access$600(ActivityThread.java:146)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1239)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.os.Handler.dispatchMessage(Handler.java:99)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.os.Looper.loop(Looper.java:137)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.ActivityThread.main(ActivityThread.java:5085)
12-14 23:07:55.332: E/AndroidRuntime(11322): at java.lang.reflect.Method.invokeNative(Native Method)
12-14 23:07:55.332: E/AndroidRuntime(11322): at java.lang.reflect.Method.invoke(Method.java:511)
12-14 23:07:55.332: E/AndroidRuntime(11322): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-14 23:07:55.332: E/AndroidRuntime(11322): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-14 23:07:55.332: E/AndroidRuntime(11322): at dalvik.system.NativeStart.main(Native Method)
12-14 23:07:55.332: E/AndroidRuntime(11322): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.mms/com.android.mms.ui.ComposeMessageActivity}; have you declared this activity in your AndroidManifest.xml?
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.Activity.startActivityForResult(Activity.java:3370)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.Activity.startActivityForResult(Activity.java:3331)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.Activity.startActivity(Activity.java:3566)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.Activity.startActivity(Activity.java:3534)
12-14 23:07:55.332: E/AndroidRuntime(11322): at com.example.shareviamms.MainActivity.onCreate(MainActivity.java:20)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.Activity.performCreate(Activity.java:5104)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-14 23:07:55.332: E/AndroidRuntime(11322): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2151)
12-14 23:07:55.332: E/AndroidRuntime(11322): ... 11 more
發佈清單 – user2511882
我添加了上面的清單。 – android
同時發佈您的錯誤的全文。 – hichris123