Android downloading bitmap from url -
I have one more minor problem, I have a link to my picture in the standard format, but by the end of the entry Auth Token is the image needed, so whenever I type it in my webbrowser with the correct auth token image, it is automatically downloaded. And here's my question, how do I support playing this kind of image in Bitmap on Android? Because
using the final URL bitmapUrl = new URL (imageUrl); Bitmap = bitmapfile SingleStream (Bitmap URL. Open Connection). GetInputStream ());
does not work ...
private Bitmap GetBitmap (string url) {file f = fileCache.getFile (url); // bitmap b = decodfile (s) from SD cache; If (b! = Null) return b; // Try the Web {bitmap bitmap = null; URL imageUrl = New URL (url); HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection (); Conn.setConnectTimeout (70000); Conn.setReadTimeout (70000); Conn.setRequestProperty ("Auth_keyName", "Value"); // If required authentication conn.setInstanceFollowRedirects (true); InputStream = conn.getInputStream (); OutputStream OS = New FileOutputStream (f); Utilis Copyright Stream (IS, OS); Os.close (); Conn.disconnect (); Bitmap = decodefile (f); Return bitmap; } Catch (Throwable Pre) {ex.printStackTrace (); If (Expression of OutofMemory Error) Memory Cache clear (); Return tap; }}
Comments
Post a Comment