Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:25:07+00:00 2026-06-09T20:25:07+00:00

I am trying to crop images selected from Gallery and the Camera . I

  • 0

I am trying to crop images selected from Gallery and the Camera. I cant crop most of the images. It’s not calling the onActivityResult(). Below is my code. And I got the following log cat output for each time I click OK after cropping the image.

Code:

private void doCrop() {
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setType("image/*");

    List<ResolveInfo> list = getPackageManager().queryIntentActivities(
            intent, 0);

    int size = list.size();
    if (size == 0) {
        Toast.makeText(this, "Can not find image crop app",
                Toast.LENGTH_SHORT).show();

        return;
    } else {
        intent.setData(mImageCaptureUri);

        // intent.putExtra("outputX", 200);
        // intent.putExtra("outputY", 200);
        // intent.putExtra("aspectX", 1);
        // intent.putExtra("aspectY", 1);
        intent.putExtra("outputX", myImg.getWidth());
        intent.putExtra("outputY", myImg.getHeight());
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 1);
        intent.putExtra("scale", true);
        intent.putExtra("return-data", true);
        intent.putExtra("outputFormat",
                Bitmap.CompressFormat.PNG.toString());
        intent.putExtra("crop", "true");

        if (size == 1) {
            Intent i = new Intent(intent);
            ResolveInfo res = list.get(0);

            i.setComponent(new ComponentName(res.activityInfo.packageName,
                    res.activityInfo.name));

            startActivityForResult(i, CROP_FROM);
        }
    }
}

LogCat:

08-13 15:59:29.220: D/skia(7247): WARNING: One-shot allocator has already allocated (alloc count = 1)
08-13 15:59:29.290: D/skia(7247): WARNING: One-shot allocator has already allocated (alloc count = 1)
08-13 15:59:30.140: D/dalvikvm(288): GC_EXPLICIT freed 8K, 8% free 6788K/7367K, paused 2ms+2ms
08-13 15:59:34.110: D/dalvikvm(7247): GC_FOR_ALLOC freed 4824K, 44% free 10227K/18055K, paused 26ms
08-13 15:59:34.110: I/dalvikvm-heap(7247): Grow heap (frag case) to 11.929MB for 1956256-byte allocation
08-13 15:59:34.140: D/dalvikvm(7247): GC_FOR_ALLOC freed <1K, 33% free 12137K/18055K, paused 23ms
08-13 15:59:34.190: D/dalvikvm(7247): GC_CONCURRENT freed 1K, 25% free 13662K/18055K, paused 2ms+3ms
08-13 15:59:34.230: D/skia(7247): WARNING: One-shot allocator has already allocated (alloc count = 1)
08-13 15:59:34.280: D/dalvikvm(7247): GC_FOR_ALLOC freed 2554K, 33% free 12132K/18055K, paused 30ms
08-13 15:59:34.310: D/skia(7247): WARNING: One-shot allocator has already allocated (alloc count = 1)
08-13 15:59:34.340: D/dalvikvm(7247): GC_FOR_ALLOC freed <1K, 27% free 13331K/18055K, paused 30ms
08-13 15:59:34.390: D/dalvikvm(7247): GC_FOR_ALLOC freed 2000K, 33% free 12132K/18055K, paused 30ms
08-13 15:59:34.420: D/skia(7247): WARNING: One-shot allocator has already allocated (alloc count = 1)
08-13 15:59:34.450: D/dalvikvm(7247): GC_FOR_ALLOC freed <1K, 26% free 13430K/18055K, paused 33ms
08-13 15:59:34.500: D/skia(7247): WARNING: One-shot allocator has already allocated (alloc count = 1)
08-13 15:59:34.530: D/dalvikvm(7247): GC_FOR_ALLOC freed 2097K, 28% free 13152K/18055K, paused 30ms
08-13 15:59:34.550: E/JavaBinder(7247): !!! FAILED BINDER TRANSACTION !!!
08-13 15:59:34.560: W/InputManagerService(142): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40988068
08-13 15:59:39.620: D/dalvikvm(224): GC_EXPLICIT freed <1K, 31% free 17001K/24391K, paused 3ms+3ms
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:25:08+00:00Added an answer on June 9, 2026 at 8:25 pm

    Please try the whole source code.

    I am using same projet. Here is the code for that activity:

    Code:

     private void doCrop() {
        final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>();
    
        Intent intent = new Intent("com.android.camera.action.CROP");
        intent.setType("image/*");
    
        List<ResolveInfo> list = getPackageManager().queryIntentActivities( intent, 0 );
    
        int size = list.size();
    
        if (size == 0) {            
            Toast.makeText(this, "Can not find image crop app", Toast.LENGTH_SHORT).show();
    
            return;
        } else {
            intent.setData(mImageCaptureUri);
    
            intent.putExtra("outputX", 200);
            intent.putExtra("outputY", 200);
            intent.putExtra("aspectX", 1);
            intent.putExtra("aspectY", 1);
            intent.putExtra("scale", true);
            intent.putExtra("return-data", true);
    
            if (size == 1) {
                Intent i        = new Intent(intent);
                ResolveInfo res = list.get(0);
    
                i.setComponent( new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
    
                startActivityForResult(i, CROP_FROM_CAMERA);
            } else {
                for (ResolveInfo res : list) {
                    final CropOption co = new CropOption();
    
                    co.title    = getPackageManager().getApplicationLabel(res.activityInfo.applicationInfo);
                    co.icon     = getPackageManager().getApplicationIcon(res.activityInfo.applicationInfo);
                    co.appIntent= new Intent(intent);
    
                    co.appIntent.setComponent( new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
    
                    cropOptions.add(co);
                }
    
                CropOptionAdapter adapter = new CropOptionAdapter(getApplicationContext(), cropOptions);
    
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle("Choose Crop App");
                builder.setAdapter( adapter, new DialogInterface.OnClickListener() {
                    public void onClick( DialogInterface dialog, int item ) {
                        startActivityForResult( cropOptions.get(item).appIntent, CROP_FROM_CAMERA);
                    }
                });
    
    
                builder.setOnCancelListener( new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel( DialogInterface dialog ) {
    
                        if (mImageCaptureUri != null ) {
                            getContentResolver().delete(mImageCaptureUri, null, null );
                            mImageCaptureUri = null;
                        }
                    }
                } );
    
                AlertDialog alert = builder.create();
    
                alert.show();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jquery jcrop to crop images. this code starts the plugin
I am trying to crop image by my custom cropper. Not from the UIImagePickerController's.
I'm trying to crop an image from the media gallery. I'm able to access
I'm trying to resize and crop images into Google App engine in order to
i got a jquery upload and crop script and i am trying to use
I'm trying to crop a list of images. The list is stored in a
I am trying to crop images using the google.appengine.api.images. Unfortunately trying to crop an
I've taken a code from here (SO) that crops images. I tried it on
I am trying to create a gridview and load some images from URLs to
I'm using Wordpress and user-uploaded images. I'm trying to build a responsive image gallery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.