First, don't set the class-name.
Your customer's phone may not have this particular activity
(com.android.camera.CropImage) installed.

But this should not give you the 'permission denial' error.
Maybe the CROP action can only crop public images. You set yours to
PRIVATE.

On Feb 12, 9:18 am, Vaibhav Goel <vaibhavgoe...@gmail.com> wrote:
> I need to crop an image whose Uri is known.
>
> In 1.6 I used the below code.
>
>  Intent i = new Intent("com.android.camera.action.CROP");
>  i.setClassName("com.android.camera", "com.android.camera.CropImage");
>  i.setData(imageUri);      // imageUri = 
> content://media/external/images/media/40
>  i.putExtra("noFaceDetection", false);
>  i.putExtra("outputX", 75);
>  i.putExtra("outputY", 75);
>  i.putExtra("aspectX", 1);
>  i.putExtra("aspectY", 1);
>  i.putExtra("scale", true);
>
>  ContentValues values = new ContentValues();
>  values.put(Media.TITLE, "User_t" + "_Image");
>  values.put(Media.BUCKET_ID, "User-T");
>  values.put(Media.BUCKET_DISPLAY_NAME, "image_t");
>  values.put(Media.IS_PRIVATE, 1);
>  userThumbnailUri = getContentResolver().insert(
>                         Media.EXTERNAL_CONTENT_URI, values);
>  i.putExtra(MediaStore.EXTRA_OUTPUT, userThumbnailUri);
> startActivityForResult(i, CROP_IMAGE);
>
> It worked fine on 1.6 but when i tested it on 2.1 it give error as
> shown below.
>
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):
> java.lang.RuntimeException: Failure delivering result
> ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://
> media/external/images/media/40 }} to activity {net.urbansignals/
> net.urbansignals.activity.user.SignUpActivity}:
> java.lang.SecurityException: Permission Denial: starting Intent
> { act=com.android.camera.action.CROP dat=content://media/external/
> images/media/40 cmp=com.android.camera/.CropImage (has extras) } from
> ProcessRecord{44ae1ac8 851:net.urbansignals/10045} (pid=851,
> uid=10045) requires null
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.ActivityThread.deliverResults(ActivityThread.java:3329)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.ActivityThread.handleSendResult(ActivityThread.java:3371)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.ActivityThread.access$2700(ActivityThread.java:119)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1893)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.os.Handler.dispatchMessage(Handler.java:99)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.os.Looper.loop(Looper.java:123)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.ActivityThread.main(ActivityThread.java:4363)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> java.lang.reflect.Method.invoke(Method.java:521)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> com.android.internal.os.ZygoteInit
> $MethodAndArgsCaller.run(ZygoteInit.java:860)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> dalvik.system.NativeStart.main(Native Method)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851): Caused by:
> java.lang.SecurityException: Permission Denial: starting Intent
> { act=com.android.camera.action.CROP dat=content://media/external/
> images/media/40 cmp=com.android.camera/.CropImage (has extras) } from
> ProcessRecord{44ae1ac8 851:net.urbansignals/10045} (pid=851,
> uid=10045) requires null
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.os.Parcel.readException(Parcel.java:1218)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.os.Parcel.readException(Parcel.java:1206)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:
> 1214)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.Instrumentation.execStartActivity(Instrumentation.java:
> 1373)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.Activity.startActivityForResult(Activity.java:2749)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> net.urbansignals.activity.user.SignUpActivity.onActivityResult(SignUpActivi­ty.java:
> 326)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.Activity.dispatchActivityResult(Activity.java:3828)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
> android.app.ActivityThread.deliverResults(ActivityThread.java:3325)
> 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     ... 11 more
>
> Can any body suggest the proper way do crop an image in 2.x ?
>
> Thanks for your suggestions.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to