/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/widget/TrainInfoWidget.java
ViewVC logotype

Annotation of /android/TrainInfo/src/dk/thoerup/traininfo/widget/TrainInfoWidget.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 572 - (hide annotations) (download)
Mon Feb 1 16:49:02 2010 UTC (14 years, 3 months ago) by torben
Original Path: android/TrainInfo/src/dk/thoerup/traininfo/TrainInfoWidget.java
File size: 2032 byte(s)
Code.sync: first try at widget
1 torben 572 package dk.thoerup.traininfo;
2    
3     import android.app.PendingIntent;
4     import android.appwidget.AppWidgetManager;
5     import android.appwidget.AppWidgetProvider;
6     import android.content.Context;
7     import android.content.Intent;
8     import android.widget.RemoteViews;
9    
10     public class TrainInfoWidget extends AppWidgetProvider {
11    
12     public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
13     final int N = appWidgetIds.length;
14    
15     // Perform this loop procedure for each App Widget that belongs to this provider
16     for (int i=0; i<N; i++) {
17     int appWidgetId = appWidgetIds[i];
18    
19     // Create an Intent to launch ExampleActivity
20     Intent intent = new Intent(context, DepartureList.class);
21    
22     StationBean bean = new StationBean();
23     bean.setRegional(true);
24     bean.setSTrain(true);
25     bean.setMetro(true);
26     bean.setDistance(12345);
27     bean.setId(10);
28     bean.setName("Bj.bro");
29     bean.setAddress("addr");
30     bean.setRegional(true);
31     bean.setSTrain(true);
32     intent.putExtra("stationbean", bean);
33     PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
34    
35     // Get the layout for the App Widget and attach an on-click listener to the button
36     RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
37     //views.setOnClickPendingIntent(R.id.widgetstation, pendingIntent);
38     views.setOnClickPendingIntent(R.id.widget, pendingIntent);
39    
40    
41     //views.setOnClickPendingIntent(R.id.widgetbutton, pendingIntent);
42     views.setTextViewText(R.id.widgetstation, "Bjerringbro");
43    
44     // Tell the AppWidgetManager to perform an update on the current App Widget
45     appWidgetManager.updateAppWidget(appWidgetId, views);
46     }
47     }
48     }

  ViewVC Help
Powered by ViewVC 1.1.20