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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用文件路徑在gallery中打開一個圖像

使用文件路徑在gallery中打開一個圖像

瀟瀟雨雨 2019-03-21 18:15:14
我在數(shù)據(jù)庫中存儲一個圖像文件路徑?,F(xiàn)在使用它我想打開 gallery 中 SD Card 的圖像。我使用的下面的代碼:File file = new File(filename);             Uri uri = Uri.fromFile(file);             Intent intent = new Intent(Intent.ACTION_VIEW, uri);             intent.setType("image/*");             startActivity(intent); /** replace with your own uri */出現(xiàn)的錯誤:06-05 08:42:23.516: E/AndroidRuntime(16815): android.content.ActivityNotFoundException: No Activity found to handle Intent  { act=android.intent.action.VIEW dat=file:///mnt/sdcard/My%20App/image_umxto_1.jpg }如何處理這個問題?
查看完整描述

2 回答

?
慕森王

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超3個贊

Intent newintent = new  Intent(android.content.Intent.ACTION_VIEW);
newintent.setDataAndType(Uri.parse(file.getAbsolutePath().toString()), "image/*");
newintent.setFlags(newintent.FLAG_ACTIVITY_NEW_TASK);
try{
      FileExplorer.this.startActivity(newintent);
   }
catch(android.content.ActivityNotFoundException e){
Toast.makeText(this, "沒有找到合適的應(yīng)用打開文件",1).show();
}


查看完整回答
反對 回復(fù) 2019-04-29
?
慕運(yùn)維8079593

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超5個贊

Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(new File(filename)), "image/*");
            startActivity(intent);
Use this code and tell me


查看完整回答
反對 回復(fù) 2019-04-29
  • 2 回答
  • 0 關(guān)注
  • 494 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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