Android 系統(tǒng)相機拍照后相片無法在相冊中顯示解決辦法
更新時間:2016年12月26日 09:47:28 投稿:lqh
這篇文章主要介紹了Android 系統(tǒng)相機拍照后相片無法在相冊中顯示解決辦法的相關(guān)資料,需要的朋友可以參考下
Android 系統(tǒng)相機拍照后相片無法在相冊中顯示解決辦法
目前自己使用發(fā)送廣播實現(xiàn)了效果
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; }
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
您可能感興趣的文章:
相關(guān)文章
android實現(xiàn)人臉識別技術(shù)的示例代碼
本篇文章主要介紹了android人臉識別技術(shù)的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-03Android開源框架的SlidingFragment的使用示例
今天小編就為大家分享一篇關(guān)于Android開源框架的SlidingFragment的使用示例,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03Kotlin中ListView與RecyclerView的應(yīng)用講解
這篇文章主要介紹了Kotlin中ListView與RecyclerView的應(yīng)用講解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-09-09SwipeLayout框架實現(xiàn)側(cè)拉刪除編輯功能
這篇文章主要為大家詳細介紹了SwipeLayout框架實現(xiàn)側(cè)拉刪除編輯功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-08-08