By removing class-name and private restrictions, it works for the
images picked from gallery but when i pass Uri of image after
capturing it from camera, it gives Activity not found exception as
shown below.

Code used:

                                Intent i = new 
Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                                 ContentValues values = new ContentValues();
                                 values.put(Media.TITLE, "User" + "_Image");
                                 values.put(Media.BUCKET_ID, "User");
                                 values.put(Media.BUCKET_DISPLAY_NAME, "image");
                                 userImageUri =
getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
                                 i.putExtra(MediaStore.EXTRA_OUTPUT, 
userImageUri);

                                 startActivityForResult(i, Get_IMAGE);

and in OnActivityResult :

Intent i = new Intent("com.android.camera.action.CROP");

                   i.setData(userImageUri);    // userImageUri is created
above

                i.putExtra("noFaceDetection", false);
                i.putExtra("outputX", iconWidth);
                i.putExtra("outputY", iconHeight);
                i.putExtra("aspectX", iconWidth);
                i.putExtra("aspectY", iconHeight);
                i.putExtra("scale", true);

                    ContentValues values = new ContentValues();
                    values.put(Media.TITLE, "1_" + " Icon");
                    values.put(Media.BUCKET_ID, "User-T");
                    values.put(Media.BUCKET_DISPLAY_NAME, "image_t");
                    iconUri =
getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
                    i.putExtra("output", iconUri);

                     startActivityForResult(i, CROP_IMAGE);

After calling crop activity after camera, it gives NoActivityFound
error as shown below:

02-16 16:26:47.306: ERROR/AndroidRuntime(684): Uncaught handler:
thread main exiting due to uncaught exception
02-16 16:26:47.467: ERROR/AndroidRuntime(684):
java.lang.RuntimeException: Failure delivering result
ResultInfo{who=null, request=1, result=-1, data=null} to activity
{com.nagarro/com.nagarro.CameraActivity}:
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=com.android.camera.action.CROP dat=content://media/
external/images/media/17 (has extras) }
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.ActivityThread.deliverResults(ActivityThread.java:3314)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.ActivityThread.handleSendResult(ActivityThread.java:3356)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.ActivityThread.access$2700(ActivityThread.java:119)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1878)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.os.Handler.dispatchMessage(Handler.java:99)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.os.Looper.loop(Looper.java:123)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.ActivityThread.main(ActivityThread.java:4338)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
java.lang.reflect.Method.invokeNative(Native Method)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
java.lang.reflect.Method.invoke(Method.java:521)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
dalvik.system.NativeStart.main(Native Method)
02-16 16:26:47.467: ERROR/AndroidRuntime(684): Caused by:
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=com.android.camera.action.CROP dat=content://media/
external/images/media/17 (has extras) }
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:
1408)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.Instrumentation.execStartActivity(Instrumentation.java:
1378)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.Activity.startActivityForResult(Activity.java:2749)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
com.nagarro.CameraActivity.onActivityResult(CameraActivity.java:113)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.Activity.dispatchActivityResult(Activity.java:3828)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     at
android.app.ActivityThread.deliverResults(ActivityThread.java:3310)
02-16 16:26:47.467: ERROR/AndroidRuntime(684):     ... 11 more



On Feb 16, 9:03 am, Streets Of Boston <[email protected]> wrote:
> 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 theCROPaction can onlycroppublic images. You set yours to
> PRIVATE.
>
> On Feb 12, 9:18 am, Vaibhav Goel <[email protected]> wrote:
>
> > I need tocropan 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.CROPdat=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.CROPdat=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 docropan 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to