首页 > 系统 > Android > 正文

Android 系统相机拍照后相片无法在相册中显示解决办法

2019-10-23 19:56:29
字体:
来源:转载
供稿:网友

Android 系统相机拍照后相片无法在相册中显示解决办法

目前自己使用发送广播实现了效果 

public void photo() {     Intent openCameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);     startActivityForResult(openCameraIntent, TAKE_PICTURE);   } 

解决方法:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {     switch (requestCode) {     case TAKE_PICTURE:       if ( resultCode == RESULT_OK) {          String fileName = String.valueOf(System.currentTimeMillis());         Bitmap bm = (Bitmap) data.getExtras().get("data");                  FileUtils.saveBitmap(bm, fileName);                  String imagePath = FileUtils.SDPATH+fileName + ".JPEG";          //将刚拍照的相片在相册中显示         Uri localUri = Uri.fromFile(new File(imagePath));         Intent localIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, localUri);         sendBroadcast(localIntent);                 }       break;     } 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


注:相关教程知识阅读请移步到Android开发频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表