There is a generic action you can use for cropping that is supported on many user devices, but not all of them. The following represents the closest we have to a standard approach to launching a cropping Activity:
Intent croppingIntent = new Intent("com.android.camera.action.CROP");
You need to pass various additional data values to the Intent before starting it, and if you want the cropped image to return to your code you need to call the Intent using startActivityForResult, then implement onActivityResult to process the returned cropped image.
So far so good, but unfortunately there are lots of Android vendors whose devices do not support this action. You have two broad options:
- Only provide your cropping functionality to users whose devices support this Intent
- Query the user device in order to target specific cropping Activities
If you opt for the first approach, you can include the code in which you call the Intent in a try block, with a catch block outputting an informative error message letting the user know why they can't complete the cropping action. If you opt for the second approach, you have a more complex task in front of you.
See this Stack Overflow post for an example of how to handle differing device crop Activities:
Android Camera Intent with Crop
For an overview of using the basic crop action above, see my tutorial on Mobiletuts+ for more details:
Capture and Crop an Image with the Device Camera
It seems the Android system is plagued a little by this type of issue. When approaching another task recently I found there is a similar problem when attempting to launch the alarm clock app on a user device - a common aim, particularly for clock widget apps.