在android公共类中,ImageDownlod扩展了AsyncTask<;字符串、空格、位图
在类ImageDownlod中,在第二个变量中使用void时给出错误 使用void时出错 此处无效时出错在android公共类中,ImageDownlod扩展了AsyncTask<;字符串、空格、位图,android,Android,在类ImageDownlod中,在第二个变量中使用void时给出错误 使用void时出错 此处无效时出错 public class ImageDownlod extends AsyncTask<String,Void, Bitmap> { @Override protected Bitmap doInBackground(String... urls) {
public class ImageDownlod extends AsyncTask<String,Void, Bitmap>
{
@Override
protected Bitmap doInBackground(String... urls) {
try {
URL url = new URL(urls[0]);
HttpsURLConnection connection=(HttpsURLConnection)url.openConnection();
connection.connect();
InputStream inputStream= connection.getInputStream();
Bitmap mybitmap = BitmapFactory.decodeStream(inputStream);
return mybitmap;
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
公共类ImageDownlod扩展异步任务
{
@凌驾
受保护位图doInBackground(字符串…URL){
试一试{
URL=新URL(URL[0]);
HttpsURLConnection连接=(HttpsURLConnection)url.openConnection();
connection.connect();
InputStream InputStream=connection.getInputStream();
位图mybitmap=BitmapFactory.decodeStream(inputStream);
返回我的位图;
}
捕获(格式错误)
{
e、 printStackTrace();
}
捕获(IOE异常)
{
e、 printStackTrace();
}
返回null;
}