1

我尝试调用MMS的 Attach Image Activity,这是我的代码:

          Intent intent2 = new Intent("com.android.mms.action.ATTACH_IMAGE");

          intent2.setType("image/*");
          intent2.putExtra(Intent.EXTRA_STREAM, mUri);

          try {
              startActivity(intent);

          } catch (ActivityNotFoundException e) {

             e.printStackTrace(System.err);
          }

但我得到了这个例外:

m.android.mms/com.android.mms.AttachImage}: java.lang.IllegalAccessException: access to class not allowed
E/AndroidRuntime(  673):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2219)
E/AndroidRuntime(  673):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2332)
E/AndroidRuntime(  673):        at android.app.ActivityThread.access$1800(ActivityThread.java:110)
E/AndroidRuntime(  673):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1717)
E/AndroidRuntime(  673):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  673):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  673):        at android.app.ActivityThread.main(ActivityThread.java:4021)
E/AndroidRuntime(  673):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  673):        at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  673):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime(  673):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
E/AndroidRuntime(  673):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  673): Caused by: java.lang.IllegalAccessException: access to class not allowed
E/AndroidRuntime(  673):        at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(  673):        at java.lang.Class.newInstance(Class.java:1472)
E/AndroidRuntime(  673):        at android.app.Instrumentation.newActivity(Instrumentation.java:1097)
E/AndroidRuntime(  673):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)

你能告诉我为什么吗?谢谢你。

4

1 回答 1

0

这可能是你想要完成的更多:

startActivity(
    new Intent(Intent.ACTION_SEND)
        .setType("image/*")
        .putExtra("sms_body", "hello there")
        .putExtra(Intent.EXTRA_STREAM, Uri.parse("content://media/external/images/media/1")
    )
);

只要您至少用相机拍摄了一张照片,您就应该能够使用此代码发送该照片。请注意,此代码不适用于模拟器。

于 2009-08-24T04:33:22.230 回答