Hi, I'm testing this code on Motorola Milestone (2.0). And I get an exception when trying to launch the Cropper:
01-27 14:29:24.210: ERROR/AndroidRuntime(1895): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.camera/com.android.camera.CropImage}; have you declared this activity in your AndroidManifest.xml? When trying the same intent without the setClassName call I get this error: 01-27 14:15:46.483: ERROR/AndroidRuntime(1813): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.camera.action.CROP dat=file:///sdcard/ tmp_contact_1264594532122.jpg (has extras) } Anyone? Also, there is no Constant for the Crop image intent. Can anyone from the Google/Android Framework team explain? It seems like it is there to be used but someone forgot to create the constant. Thanks On Dec 29 2009, 8:30 pm, Wysie <sohyuanc...@gmail.com> wrote: > Hi all, > > After doing some reading, I realized it can't be done so simply. My > modded Contacts source is athttp://github.com/Wysie, you can take a > look if you're interested. Also, here's what I did to get it working: > > private void doTakePhotoAction() { > //http://2009.hfoss.org/Tutorial:Camera_and_Gallery_Demo > > //http://stackoverflow.com/questions/1050297/how-to-get-the-url-of-the-... > //http://www.damonkohler.com/2009/02/android-recipes.html > //http://www.firstclown.us/tag/android/ > // The one I used to get everything > working:http://groups.google.com/group/android-developers/msg/2ab62c12ee99ba30 > > Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); > > //Wysie_Soh: Create path for temp file > mImageCaptureUri = Uri.fromFile(new File > (Environment.getExternalStorageDirectory(), > "tmp_contact_" + String.valueOf > (System.currentTimeMillis()) + ".jpg")); > > intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, > mImageCaptureUri); > > try { > intent.putExtra("return-data", true); > startActivityForResult(intent, PICK_FROM_CAMERA); > } catch (ActivityNotFoundException e) { > //Do nothing for now > } > } > > protected void onActivityResult(int requestCode, int resultCode, > Intent data) { > if (resultCode != RESULT_OK) { > return; > } > > switch (requestCode) { > > case CROP_FROM_CAMERA: { > //Wysie_Soh: After a picture is taken, it will go to > PICK_FROM_CAMERA, which will then come here > //after the image is cropped. > > final Bundle extras = data.getExtras(); > > if (extras != null) { > Bitmap photo = extras.getParcelable("data"); > > mPhoto = photo; > mPhotoChanged = true; > mPhotoImageView.setImageBitmap(photo); > setPhotoPresent(true); > } > > //Wysie_Soh: Delete the temporary > file > File f = new File(mImageCaptureUri.getPath()); > if (f.exists()) { > f.delete(); > } > > InputMethodManager mgr = (InputMethodManager) > getSystemService(Context.INPUT_METHOD_SERVICE); > mgr.showSoftInput(mPhotoImageView, > InputMethodManager.SHOW_IMPLICIT); > > break; > } > > case PICK_FROM_CAMERA: { > //Wysie_Soh: After an image is taken and saved to the > location of mImageCaptureUri, come here > //and load thecropeditor, with the necessary parameters > (96x96, 1:1 ratio) > > Intent intent = new Intent > ("com.android.camera.action.CROP"); > intent.setClassName("com.android.camera", > "com.android.camera.CropImage"); > > intent.setData(mImageCaptureUri); > intent.putExtra("outputX", 96); > intent.putExtra("outputY", 96); > intent.putExtra("aspectX", 1); > intent.putExtra("aspectY", 1); > intent.putExtra("scale", true); > intent.putExtra("return-data", true); > startActivityForResult(intent, CROP_FROM_CAMERA); > > break; > > } > } > } > > Hope it helps :) -- 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