开发者

How to load images in AppWidgetProvider class onUpdate()?

开发者 https://www.devze.com 2023-03-26 00:43 出处:网络
I want to load some images into the RemoteView but i dont how to do it inside of the onUpdate(). How would i go about doing it with this?

I want to load some images into the RemoteView but i dont how to do it inside of the onUpdate().

How would i go about doing it with this?

 @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){

    for(int i = 0; i < appWidgetIds.length; ++i){

        Intent intent = new Intent(context, StackWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);

        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

        rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

        rv.setEmptyView(R.id.stack_view, R.id.add);

        Intent toastIntent = new Intent(context, stackWidgetProvider.class);
        toastIntent.setAction(stackWidgetProvider.TOAST_ACTION);
        toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);

        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);


    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);

}

I want to load some images from a URL i know how to do this part. I just dont know how to set them in the onUpdate(). They come in as a BitMap.

How would i set them to the RemoteView in t开发者_C百科he onUpdate()?


Remoteview.setImageViewUri
Remoteview.setBitmap
Remoteview.setImageViewBitmap
Remoteview.setImageViewResource
0

精彩评论

暂无评论...
验证码 换一张
取 消