Widget Not showing up after phone restart
android, android-widget
Solution
When phone restart, it will call onEnable instead of onUpdate.
--update--
int[] allids = AppWidgetManager
.getInstance(Context)
.getAppWidgetIds(new ComponentName(Context, YourAppWidgetProvider.class);
This will get all ids that is under the control of YourAppWigetProvider. Read more on this
Problem
I created a widget that works great until I restart the phone, then the widget doesn't display it is invisible but if i hold and click i can throw it in the garbage I have a function that is called from my configure activity in my widgetprovider that does the following: ``` static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, int version) { if(savedType == -1) savedType = version; // android.os.Debug.waitForDebugger(); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main); Intent configIntent = new Intent(context, Configure.class); configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); Uri data = Uri.withAppendedPath( Uri.parse(appWidgetId + "://widget/id/") ,String.valueOf(appWidgetId)); configIntent.setData(data); PendingIntent pendingIntent = PendingIntent.getActivity (context, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT); views.setOnClickPendingIntent(R.id.MainImage,pendingIntent); views.setImageViewResource(R.id.MainImage, lv_images[version]); appWidgetManager.updateAppWidget(appWidgetId, views); } ``` I had my onUpdate not doing anything because there is never anything to update but thinking this would be called after a phone restart i copied the code i had in the function ``` for(int i = 0; i < appWidgetIds.length; ++i) { updateAppWidget(context, appWidgetManager, appWidgetIds[i], savedType); } ``` but this didn't seem to do much either.... suggestions?