第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

uri字符串不能在android中緩存

uri字符串不能在android中緩存

炎炎設(shè)計(jì) 2019-03-21 18:19:56
我使用的下面的代碼String fileName = "image" + "_" + title.getText().toString()+"_" + val.toString();                      photo = this.createFile(fileName, ".jpg");                     intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));                     uriOfPhoto = Uri.fromFile(photo);                     startActivityForResult(intent, RESULT_CAMERA_SELECT);                 }             }             catch(Exception e)             {                 Log.v("Error", "Can't create file to take picture!");                 displayAlert("Can't create file to take picture!","SDCard Error!");             }         }         private File createFile(String part, String ext) throws Exception         {             File tempDir = new File (Environment.getExternalStorageDirectory() + "/MyFolder/Images");             if(!tempDir.exists())             {                 tempDir.mkdir();             }             tempDir.canWrite();             return new File(tempDir, part+ext);         }     });UriOfPhoto 給出提示uriString not chached in debug。它不是存儲(chǔ)文件中的uri。如何解決這個(gè)問(wèn)題呢?authority   Uri$Part$EmptyPart  (id=830004244032)    fragment    Uri$Part$EmptyPart  (id=830004245408)    host    "NOT CACHED" (id=830003914304)   path    Uri$PathPart  (id=830067926736)  port    -2   query   Uri$Part$EmptyPart  (id=830004245408)    scheme  "file" (id=830002660688)     ssp null     uriString   "NOT CACHED" (id=830003914304)   userInfo    null
查看完整描述

2 回答

?
婷婷同學(xué)_

TA貢獻(xiàn)1844條經(jīng)驗(yàn) 獲得超8個(gè)贊

photo 的值是確定的,

photo = this.createFile(fileName, ".jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
uriOfPhoto = Uri.fromFile(photo);

為什么還在這里實(shí)例化uriOfPhoto, 有點(diǎn)多余。 在用到的時(shí)候在實(shí)例化


查看完整回答
反對(duì) 回復(fù) 2019-04-29
?
互換的青春

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊

String fileName = Environment.getExternalStorageDirectory() + "/MyFolder/Images" + fileName + ".jpg";
UriOfPhoto = Uri.parse(fileName);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra(MediaStore.EXTRA_OUTPUT,  UriOfPhoto);
startActivityForResult(intent, RESULT_CAMERA_SELECT);

不需要?jiǎng)?chuàng)建文件來(lái)存儲(chǔ)照片,你只需要傳遞 uri,它里面的照片必須是像android系統(tǒng)創(chuàng)建的文件一樣,然后在 uri 中存儲(chǔ)捕捉的圖像。


查看完整回答
反對(duì) 回復(fù) 2019-04-29
  • 2 回答
  • 0 關(guān)注
  • 390 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)