Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a simple application in android studio to take the picture from the gallery with the image croper.

When I click on the button it takes me to the gallery but cannot crop the image . I used the library as:
Java
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'


And I added the activity in the manifest .

<activity  
 android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
 android:theme="@style/Base.Theme.AppCompat"/> 

Java code

Java
photo.setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View v) {

//Intent imageDownload = new Intent(Intent.ACTION_PICK, 
 MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

 Intent imageDownload=new Intent();
 imageDownload.setAction(Intent.ACTION_GET_CONTENT);
 imageDownload.setType("image/*");
 startActivityForResult(imageDownload, GALLERY_REQUEST_CODE);
    });
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, 
 Intent data) {
 super.onActivityResult(requestCode, resultCode, data);
 if(requestCode==GALLERY_REQUEST_CODE && requestCode==RESULT_OK) {
 Uri imageUri=data.getData();
 CropImage.activity(imageUri)
      .setGuidelines(CropImageView.Guidelines.ON)
        .start(this);
 } 
 if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
 Uri resultUri = result.getUri();
 m.setImageURI(resultUri);
 } 
 else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
 Exception error = result.getError();
 }
 } 


What I have tried:

C#
I am using android studio 2.2.1. And android version lollipop 21.
Posted
Updated 2-Dec-16 7:38am
v2

1 solution

Did you start CropImageActivity from your activity?
Java
CropImage.activity(imageUri)
  .setGuidelines(CropImageView.Guidelines.ON)
  .start(this);

Read their github doc properly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900