0
URL의 이미지를 위젯의 이미지 뷰로로드하려고합니다.위젯의 URL에서 ImageView로드 - android
지금 AsyncTask 클래스를 사용하고 있습니다. 이미지가로드되지 않습니다.
public class MyWidgetIntentReceiver extends BroadcastReceiver {
public static int clickCount = -1;
private String msg[] = null;
private Context con ;
RemoteViews remoteViews ;
String url = "" ;
ImageLoader imageLoader ;
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(WidgetUtils.WIDGET_UPDATE_ACTION)) {
con = context ;
if(clickCount == 0 || clickCount > 10){
//get values
getTenLastItems();
}else{
updateWidgetPictureAndButtonListener(context);
}
}
}
private void updateWidgetPictureAndButtonListener(Context context) {
remoteViews = new RemoteViews(context.getPackageName(),
R.layout.widgets_layout);
UtilityFunctions utilityFunctions = new UtilityFunctions();
String title = utilityFunctions.getTitleWidget(context, clickCount);
// updating view
remoteViews.setTextViewText(R.id.txt_view_title_widgets,title);
//url = "http://www.shadyab.com/assests/images/upload/yuu1.jpg" ;
new MyAsyncTask().execute((Void)null);
// re-registering for click listener
remoteViews.setOnClickPendingIntent(R.id.sync_button,
MyWidgetProvider.buildButtonPendingIntent(context));
MyWidgetProvider.pushWidgetUpdate(context.getApplicationContext(),
remoteViews);
}
class MyAsyncTask extends AsyncTask<Void, Void, Bitmap>
{
@Override
protected Bitmap doInBackground(Void... urls) {
URL url;
Bitmap bmp = null ;
try {
url = new URL("http://www.shadyab.com/assests/images/upload/yuu1.jpg");
bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bmp;
}
@Override
protected void onPostExecute(Bitmap bmp) {
super.onPostExecute(bmp);
if (bmp != null) {
Log.e("error", "is not null");
remoteViews.setImageViewBitmap(R.id.img_view_main_pic_image_widgets,bmp);
}else{
Log.e("error", "is null");
}
}
}
내 로그 고양이 :
는
01-21 21:37:10.321: E/error(18618): is not null