应用程序崩溃了吗

应用程序崩溃了吗

本文介绍了当我们从图库上传图像时,应用程序崩溃了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我是android的新手,所以,如果您发现任何错误,请告诉我.当我们点击图库时.

I am new in android so, if you found any mistake please tell me.Now come to the point what i got the problem we click on image view then one popup will come and choose from where you want to upload the image so when we click on gallery then.

mProfileImageView.setOnClickListener(new View.OnClickListener() {
    @TargetApi(Build.VERSION_CODES.M)
    @Override
    public void onClick(View v) {
        new AlertDialog.Builder(ProfileActivity.this)
                .setTitle("Profile Picture")
                .setMessage("change your profile picture with")
                .setPositiveButton(R.string.capture_image, new

            DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // continue with delete
                    captureImage();
                }
            })
            *//*.setNegativeButton(R.string.choose_image, new

            DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // do nothing
                    chooseImage();
                }
            })*//*
                .setIcon(android.R.drawable.ic_dialog_alert)
                .show();
        }
    });

    public void chooseImage() {
    try {
        Intent i = new Intent(Intent.ACTION_PICK,
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        i.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, IMAGE_QUALITY_LOW);
        i.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, 0);
        i.putExtra(MediaStore.EXTRA_SIZE_LIMIT, IMAGE_MAX_SIZE);
        i.setType("image/*");
        //i.setAction(Intent.ACTION_GET_CONTENT);

        /*i.putExtra("crop", "true");
        i.putExtra("aspectX", 0);
        i.putExtra("aspectY", 0);
        i.putExtra("outputX", 400);
        i.putExtra("outputY", 400);
        i.putExtra("return-data", true);*/

        startActivityForResult(Intent.createChooser(i, "Complete action using"), GALLERY_IMAGE_ACTIVITY_REQUEST_CODE);
    } catch (ActivityNotFoundException anfe) {
        //display an error message
        String errorMessage = "Oops - your device doesn't have gallery!";
        Toast.makeText(getApplicationContext(), errorMessage,
            Toast.LENGTH_LONG).show();
    }
}

当我们滚动查看10-20张G画廊图像并准备上传时,它崩溃了,我不知道为什么?

When we are scrollingG 10-20 gallery images and going for upload at that time it's crashing i don't know why?

推荐答案

由于您正在谈论多个图像,因此您将收到 OutOfMemoryException .这是您的选择:

You are receiving an OutOfMemoryException since you are talking about several images. Here are your options:

    通过在应用程序部分的AndroidManifest.xml中添加以下行,从虚拟机中请求更大的堆: android:largeHeap ="true"
  • 尝试为画廊使用尽可能小的图像.记住:每个图像都未压缩地存储到您的应用程序堆中
  • 回收当前不可见的图像,使用 Bitmap.recycle()释放新的内存.
  • Request a larger heap from the virtual machine by adding the following line into your AndroidManifest.xml in the application section: android:largeHeap="true"
  • Try to use images as small as possible for your gallery. Remeber: each image is stored uncompressed into your applications heap
  • Recycle images that are not visible at the moment using Bitmap.recycle() to free new memory.

这篇关于当我们从图库上传图像时,应用程序崩溃了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:46