Guest User

Untitled

a guest
Jul 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. @Override
  2. public RemoteViews getViewAt(int position) {
  3.  
  4. RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
  5.  
  6.  
  7. Bundle extras = new Bundle();
  8. extras.putInt(stackWidgetProvider.EXTRA_ITEM, position);
  9. Intent fillnIntent = new Intent();
  10. fillnIntent.putExtras(extras);
  11. rv.setOnClickFillInIntent(R.id.widget_item, fillnIntent);
  12. rv.setImageViewBitmap(R.id.wigdetView, bm);
  13. MyTask myTask = new MyTask();
  14. myTask.execute();
  15.  
  16.  
  17. //Do heavy lifting here, Downloading images from a network or website.
  18.  
  19. return rv ;
  20. }
  21.  
  22. 08-01 19:48:00.520: ERROR/RemoteViewsAdapter(14319): Error in updateRemoteViews(24): null
  23. 08-01 19:48:05.530: ERROR/AppWidgetService(131): Error (unbindRemoteViewsService): Connection not bound
  24.  
  25. public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  26.  
  27. for(int i = 0; i < appWidgetIds.length; ++i) {
  28.  
  29. Intent intent = new Intent(context, StackWidgetService.class);
  30. intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
  31.  
  32. intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
  33. RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
  34.  
  35. rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);
  36.  
  37. rv.setEmptyView(R.id.stack_view, R.id.add);
  38.  
  39. Intent toastIntent = new Intent(context, stackWidgetProvider.class);
  40. toastIntent.setAction(stackWidgetProvider.TOAST_ACTION);
  41. toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
  42.  
  43. intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
  44. PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  45. rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);
  46.  
  47. appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
  48. }
Add Comment
Please, Sign In to add comment