android+rr+samsungs3,android – 相机意图数据在三星S3中的onActivityResult(int requestCode,int resultCode,Intent数据...

我遇到了同样的问题,并在下面工作,一定会帮助你解决一次:

对于解决方案我已经提到以下链接来解决问题:

写下面的代码调用捕获的图像时:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

startActivityForResult(intent, PICK_FROM_CAMERA);

并通过OnActivityResult()方法获取您的URI方法:

if (resultCode != RESULT_OK)

return;

switch (requestCode) {

case PICK_FROM_CAMERA:

Log.i("TAG", "Inside PICK_FROM_CAMERA");

// Describe the columns you'd like to have returned. Selecting from

// the Thumbnails location gives you both the Thumbnail Image ID, as

// well as the original image ID

try {

Log.i("TAG", "inside Samsung Phones");

String[] projection = {

MediaStore.Images.Thumbnails._ID, // The columns we want

MediaStore.Images.Thumbnails.IMAGE_ID,

MediaStore.Images.Thumbnails.KIND,

MediaStore.Images.Thumbnails.DATA };

String selection = MediaStore.Images.Thumbnails.KIND + "=" + // Select

// only

// mini's

MediaStore.Images.Thumbnails.MINI_KIND;

String sort = MediaStore.Images.Thumbnails._ID + " DESC";

// At the moment, this is a bit of a hack, as I'm returning ALL

// images, and just taking the latest one. There is a better way

// to

// narrow this down I think with a WHERE clause which is

// currently

// the selection variable

Cursor myCursor = this.managedQuery(

MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,

projection, selection, null, sort);

long imageId = 0l;

long thumbnailImageId = 0l;

String thumbnailPath = "";

try {

myCursor.moveToFirst();

imageId = myCursor

.getLong(myCursor

.getColumnIndexOrThrow(MediaStore.Images.Thumbnails.IMAGE_ID));

thumbnailImageId = myCursor

.getLong(myCursor

.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID));

thumbnailPath = myCursor

.getString(myCursor

.getColumnIndexOrThrow(MediaStore.Images.Thumbnails.DATA));

} finally {

// myCursor.close();

}

// Create new Cursor to obtain the file Path for the large image

String[] largeFileProjection = {

MediaStore.Images.ImageColumns._ID,

MediaStore.Images.ImageColumns.DATA };

String largeFileSort = MediaStore.Images.ImageColumns._ID

+ " DESC";

myCursor = this.managedQuery(

MediaStore.Images.Media.EXTERNAL_CONTENT_URI,

largeFileProjection, null, null, largeFileSort);

String largeImagePath = "";

try {

myCursor.moveToFirst();

// This will actually give yo uthe file path location of the

// image.

largeImagePath = myCursor

.getString(myCursor

.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATA));

mImageCaptureUri = Uri.fromFile(new File(

largeImagePath));

} finally {

// myCursor.close();

}

// These are the two URI's you'll be interested in. They give

// you a

// handle to the actual images

Uri uriLargeImage = Uri.withAppendedPath(

MediaStore.Images.Media.EXTERNAL_CONTENT_URI,

String.valueOf(imageId));

Uri uriThumbnailImage = Uri.withAppendedPath(

MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,

String.valueOf(thumbnailImageId));

// I've left out the remaining code, as all I do is assign the

// URI's

// to my own objects anyways...

} catch (Exception e) {

Log.i("TAG",

"inside catch Samsung Phones exception " + e.toString());

}

try {

Log.i("TAG", "URI Normal:" + mImageCaptureUri.getPath());

} catch (Exception e) {

Log.i("TAG", "Excfeption inside Normal URI :" + e.toString());

}

//doCrop();

break;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值