I ran into the same problem
Finally, the solution I found was to run ACTION_GET_CONTENT, not ACTION_PICK, and then make sure that you provide MediaStore.EXTRA_OUTPUT additionally with uri to the temporary file. Here is the code to start the intent:
public class YourActivity extends Activity { File mTempFile; int REQUEST_CODE_CHOOSE_PICTURE = 1; (...) public showImagePicker() { mTempFile = getFileStreamPath("yourTempFile"); mTempFile.getParentFile().mkdirs(); Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null); intent.setType("image/*"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mTempFile)); intent.putExtra("outputFormat",Bitmap.CompressFormat.PNG.name()); startActivityForResult(intent,REQUEST_CODE_CHOOSE_PICTURE); } (...) }
You may need mTempFile.createFile ()
Then in onActivityResult you can get the image this way
protected void onActivityResult(int requestCode, int resultCode, Intent data) { case REQUEST_CODE_CHOOSE_PICTURE: Uri imageUri = data.getData(); if (imageUri == null || imageUri.toString().length() == 0) { imageUri = Uri.fromFile(mTempFile); file = mTempFile; } if (file == null) {
Hope this helps
Then you should delete your temporary file at the end (it is in the internal storage as it is, but you can use external storage, I think it would be better).
darune May 12 '11 at 12:43 2011-05-12 12:43
source share