Advertisement
Ankhwatcher

StockWidgetProvider

May 20th, 2013
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. public class StockWidgetProvider extends AppWidgetProvider {
  2.  
  3.     public static final String CHART_LINK = "callback_URL";
  4.  
  5.     protected static final String JSON_RETRIEVED = "json_retrieved";
  6.  
  7.     Context theContext;
  8.  
  9.     @SuppressWarnings("deprecation")
  10.     @Override
  11.     public void onUpdate(Context ctxt, AppWidgetManager appWidgetManager,
  12.             int[] appWidgetIds) {
  13.         Log.d(this.getClass().getName(), "onUpdate called.");
  14.         for (int i = 0; i < appWidgetIds.length; i++) {
  15.             Log.d(this.getClass().getName(), "Updating Widget: " + i);
  16.             Intent svcIntent = new Intent(ctxt, StockWidgetService.class);
  17.  
  18.             svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
  19.                     appWidgetIds[i]);
  20.             svcIntent.setData(Uri.parse(svcIntent
  21.                     .toUri(Intent.URI_INTENT_SCHEME)));
  22.  
  23.             RemoteViews widget = new RemoteViews(ctxt.getPackageName(),
  24.                     R.layout.trending_item);
  25.  
  26.             widget.setRemoteAdapter(appWidgetIds[i], R.id.favorite_listview,
  27.                     svcIntent);
  28.  
  29.             Intent browserIntent = new Intent(Intent.ACTION_VIEW,
  30.                     Uri.parse("http://www.google.com"));
  31.  
  32.             PendingIntent clickPI = PendingIntent.getActivity(ctxt, 0,
  33.                     browserIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  34.  
  35.             widget.setPendingIntentTemplate(R.id.favorite_listview, clickPI);
  36.  
  37.             appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
  38.  
  39.         }
  40.  
  41.         super.onUpdate(ctxt, appWidgetManager, appWidgetIds);
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement