0

I there a way to getting picture(image) from URL without downloading? I use the code below to get streaming video and audio. But it doesn't work with picture.

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 }

I don't want to download a file before I open it. I'll appreciate your answers. Thanks.

4

1 に答える 1

4

You can't use the "native image viewer" to display an image from the web, but you can easily pass the url to the default browser, and it should automatically load it for you. You need to append an http:// prefix for Android tell that you're trying to use the browser as the activity to handle that intent.

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://scarlettjohansson.com/wholesome.png"));
startActivity(intent);
于 2012-06-08T03:45:53.130 に答える