使用隐式意图发送多个图像



我正在尝试使用意图从我的DIRECTORY_PICTURES发送多个图像。我写了以下代码。但是当我单击按钮时,它说"不幸的是停止了"。我尝试调试,但无法。.任何建议??

case R.id.button5:
        File pictures = Environment
                .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
        String[] listofpics = pictures.list();
        Uri uri = null;
        ArrayList <Uri> arraylist = new ArrayList<Uri>(); 
        for(String picture : listofpics){
            uri = Uri.parse("file://" + pictures.toString() + "/" + picture);
            arraylist.add(uri);
        }
        i = new Intent(Intent.ACTION_SEND_MULTIPLE);
        i.setType("image/*");
        i.putExtra(Intent.EXTRA_STREAM, arraylist);
        chooser = Intent.createChooser(i, "Send Images : ");
        startActivity(chooser);
        break;
    }

附言我也尝试放置权限..但仍然没有用..

>                <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
>                <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
>                <uses-permission android:name="android.permission.INTERNET"/>

日志猫 :

11-23 14:07:53.490: E/AndroidRuntime(12264): FATAL EXCEPTION: main
11-23 14:07:53.490: E/AndroidRuntime(12264): java.lang.IllegalStateException: Could not execute method of the activity
11-23 14:07:53.490: E/AndroidRuntime(12264):    at android.view.View$1.onClick(View.java:3599)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at android.view.View.performClick(View.java:4204)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at android.view.View$PerformClick.run(View.java:17355)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at android.os.Handler.handleCallback(Handler.java:725)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at android.os.Looper.loop(Looper.java:137)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at android.app.ActivityThread.main(ActivityThread.java:5041)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at java.lang.reflect.Method.invokeNative(Native Method)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at java.lang.reflect.Method.invoke(Method.java:511)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at dalvik.system.NativeStart.main(Native Method)
11-23 14:07:53.490: E/AndroidRuntime(12264): Caused by: java.lang.reflect.InvocationTargetException
11-23 14:07:53.490: E/AndroidRuntime(12264):    at java.lang.reflect.Method.invokeNative(Native Method)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at java.lang.reflect.Method.invoke(Method.java:511)
11-23 14:07:53.490: E/AndroidRuntime(12264):    at android.view.View$1.onClick(View.java:3594)
11-23 14:07:53.490: E/AndroidRuntime(12264):    ... 11 more
11-23 14:07:53.490: E/AndroidRuntime(12264): Caused by: java.lang.NullPointerException
11-23 14:07:53.490: E/AndroidRuntime(12264):    at com.example.interviewprep.Intents.launchStuff(Intents.java:80)
11-23 14:07:53.490: E/AndroidRuntime(12264):    ... 14 more

谢谢!

您可以尝试使用此链接来指导您的道路:

链接 1 - 查看接受的答案。

1:使用图库视图和链接选择多个图像 2

但没有得到我正在寻找的 Ans.. 但我找到了替代解决方案.从内置图库中获取所有图像,并将其设置为我们所有的自定义Gellery..请查看此链接自定义图库与复选框

我希望它能帮助你。

感谢这篇文章

相关内容

  • 没有找到相关文章

最新更新