No i dont. i cant find a way to get the appWidgetId required by it within my
service when i try
AppWidgetManager.getInstance(getApplicationContext()).updateAppWidget(appWidgetId,
remoteView);
the only other place it could possibly be called is in widget itself but i
cant find how to call it there either. My code for the widget is below.
public class SignalSpotWidget extends AppWidgetProvider{
public SharedPreferences sharedPreferences;
Context globalCon;
final String TAG = "SignalSpot";
AppWidgetManager globalAppWidgetManager;
int[] globalAppWidgetIds;
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
final int N = appWidgetIds.length;
globalCon=context;
globalAppWidgetManager = appWidgetManager;
globalAppWidgetIds = appWidgetIds;
// Perform this loop procedure for each App Widget that belongs to
this provider
for (int i=0; i<N; i++) {
int appWidgetId = appWidgetIds[i];
Log.i(TAG,"Widget onUpdated");
// Create an Intent to launch ExampleActivity
Intent intent = new Intent(context,
SignalSpotWidgetService.class);
PendingIntent pendingIntent = PendingIntent.getService(context,
0, intent, 0);
// Get the layout for the App Widget and attach an on-click
listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.widget_layout);
views.setOnClickPendingIntent(R.id.widgetButton, pendingIntent);
// Tell the AppWidgetManager to perform an update on the current
App Widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en