Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...

Task #618662 » Util.java

洪磊 张, 2016-12-08 03:18 PM

 
package com.example.a15530.qq20161208;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
* Created by 15530 on 2016/12/8.
*/

public class Util {
public static String TAG="UTIL";
public static Bitmap getbitmap(String imageUri) {
Log.v(TAG, "getbitmap:" + imageUri);
// 显示网络上的图片
Bitmap bitmap = null;
try {
URL myFileUrl = new URL(imageUri);
HttpURLConnection conn = (HttpURLConnection) myFileUrl
.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is);
is.close();

Log.v(TAG, "image download finished." + imageUri);
} catch (IOException e) {
e.printStackTrace();
Log.v(TAG, "getbitmap bmp fail---");
return null;
}
return bitmap;
}
}
(4-4/4)