手機拍照呼叫相簿剪下時遇到的問題

2021-08-22 10:17:13 字數 1024 閱讀 4675

最近在開發的時候遇到了選取並剪下的功能,本來想著這功能並不難,就沒有很在意在搞定了7.0許可權後**一氣呵成,寫完那自己的手機一測,完美執行沒問題,但是當專案提交到測試那裡時卻出現了問題他的手機裁剪後無法儲存,當時我一臉茫然,拿來他的手機一看是錘子的,我去羅哥的手機這是第一次見有人用,當時我就把手機拿來測了下,結果發現了個奇怪的問題。

當時我的**是這樣的

private void cropimageuri(uri sourceuri, uri tagrgeturi, int outputx, int outputy, int requestcode) 

intent.putextra("scale", true);

intent.putextra(mediastore.extra_output, tagrgeturi);

// 設定不返回資料,防止有些過大,傳回bitmap出錯

intent.putextra("return-data", false);

intent.putextra("nofacedetection", true); // no face detection

intent.putextra("outputformat", bitmap.compressformat.jpeg.tostring());

log.d(tag, "cropimageuri: -----"+bitmap.compressformat.jpeg.tostring());

startactivityforresult(intent, requestcode);

}

if (tmpfile != null && tmpfile.length() > 0) else if (tmpfile!=null&&tmpfile.length() == 0) catch (filenotfoundexception e)
當檔案長度為0是,先用url把生成bitmap在把bitmap轉成檔案,這樣就完美解決了這個問題。問題雖然解決了但我並不清楚為什麼會這樣,如果大家知道請告知我謝謝

Android呼叫系統相簿和系統相機拍照

呼叫系統相機拍照 intent new intent mediastore.action image capture startactivityforresult intent,result camara image result camara image activity的標誌。自已定義 呼叫系統...

Android 呼叫相機拍照並顯示,開啟相簿並顯示

設定拍照儲存路徑並將之轉換為uri 啟動相機,並傳遞該uri作為引數 在儲存路徑讀取 並顯示 private void takephoto outputimage.createnewfile catch ioexception e if build.version.sdk int 24 else 啟...

Android呼叫系統相簿或拍照實現頭像更換

1 展示更改頭像選擇對話方塊 override public void showmodifyheadicondialog autorelativelayout rl album autorelativelayout view.findviewbyid r.id.rl album rl album.s...