我有沒有辦法從URL獲取圖片(圖片)而無需下載?我使用下面的代碼來獲得流媒體視頻和音頻。但它不適用於圖片。Android - 無需下載即可從網址獲取圖片
public static void IntentPlayer(Context context, Uri uri, int mode){
String type;
switch(mode){
case 1: type = "video/*"; break;
case 2: type = "audio/*"; break;
case 3: type = "image/*"; break;
default: return;
}
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(uri, type);
context.startActivity(intent);
}
的logcat:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://192.168.43.1:6789/mobile_base/Tulips.jpg typ=image/* flg=0x10000000 }
我不想下載的文件之前,我打開它。我會感謝你的回答。謝謝。
你試圖對圖像做什麼?下載圖像,然後在應用程序的視圖中顯示它? – Stevy888
什麼都沒有。只顯示給用戶。 – Nolesh
顯示如何?在應用程序中,在瀏覽器中,什麼? – Stevy888