Hello guys I’m creating an application that have a widget
the application and the widget works perfectly
but if I restart the phone the application will crash
I assume this because my widget using some function from the main activity
I’ve read about the widget is calling onEnabled after reboot
so I’m trying to create an temporary view after a reboot
this is my onEnabled code
@Override
public void onEnabled(Context context) {
Log.i("INDEX", "WIDGET Enabled");
AppWidgetManager mgr = AppWidgetManager.getInstance(context);
// Get the layout for the App Widget
RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.widget_restart);
ComponentName comp = new ComponentName(context.getPackageName(),Widget.class.getName());
mgr.updateAppWidget(comp, views);
}
and can I use logcat to trace the error ?
because the logcat doesn’t show any log even I added log in the code above
can anyone please explain how the widget really work after the reboot?
or give me another alternative?
thank you
OK I have found the solution
It’s because I used onReceive() function
if I delete/comment the onReceive function
the onEnable and onUpdate will work perfectly
thanks