1

i want to display images stored in my dropbox via a webview. when i try to load the url given from dropbox i only get the dropbox layout and the name of the image in the center , is there a way to do this? If no , how can i display images stored in a cloud like Google Drive in my app?I cannot store them all in the app because of their size.Thanks in advance!

My code

 WebView webView = (WebView) view.findViewById(R.id.catalogImageSlide); 
        webView.loadUrl(null);
        //webView.loadUrl("file:///android_res/drawable/"+getArguments().getString("img"));
        webView.loadUrl("https://www.dropbox.com/s/ftd2x383ps8kbrd/046.jpg");
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);
sarakinos
  • 666
  • 11
  • 28
  • Have you set the `INTERNET` permission in your manifest file ? – GrIsHu Oct 03 '13 at 12:56
  • 1
    You might prefer to use `dl.dropboxusercontent.com` instead: https://dl.dropboxusercontent.com/s/ftd2x383ps8kbrd/046.jpg (just replace the domain name). That's a link directly to the image rather than a Dropbox page that previews the image. – user94559 Oct 03 '13 at 16:27
  • Thanks!It's the solution to my problem, amazing how simple can be sometimes!Thank you all! – sarakinos Oct 11 '13 at 13:47

1 Answers1

2

You can modify URL dropbox image before load in a WebView:

public static String modifyDropboxUrl(String originalUrl){
    String newUrl = originalUrl.replace("www.dropbox." ,"dl.dropboxusercontent.");
    //just for sure for case if www is missing in url string
    newUrl = newUrl.replace("dropbox.", "dl.dropboxusercontent.");
    return newUrl;
}

Link to original response: https://stackoverflow.com/a/20593584

Community
  • 1
  • 1
Moises Portillo
  • 828
  • 8
  • 12