如何限制用户只选择图库中的少量图片?

时间:2019-04-02 06:25:42

标签: java android

当我从图库中获取许多图像时,application崩溃了 帮我从画廊挑选至少10张图片

我使用此代码:

Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"),
                          PICK_IMAGE_MULTIPLE);

错误:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: android.itgdeveloper.com.qainshpection, PID: 7514
    java.lang.OutOfMemoryError: Failed to allocate a 19660812 byte allocation with 967032 free bytes and 944KB until OOM
        at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
        at android.graphics.Bitmap.nativeCreate(Native Method)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:856)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:823)
        at android.itgdeveloper.com.qainshpection.core.ImageHelper.getRoundedCornerBitmap(ImageHelper.java:17)
        at android.itgdeveloper.com.qainshpection.Model.KIK_ImageAdapter.getView(KIK_ImageAdapter.java:108)
        at android.widget.AbsListView.obtainView(AbsListView.java:2491)
        at android.widget.GridView.makeAndAddView(GridView.java:1444)
        at android.widget.GridView.makeRow(GridView.java:371)
        at android.widget.GridView.fillDown(GridView.java:312)
        at android.widget.GridView.fillFromTop(GridView.java:447)
        at android.widget.GridView.layoutChildren(GridView.java:1288)
        at android.widget.AbsListView.onLayout(AbsListView.java:2249)
        at android.view.View.layout(View.java:17838)
        at android.view.ViewGroup.layout(ViewGroup.java:5754)

0 个答案:

没有答案