Code like this works well.
Intent configIntent = new Intent (context, WidgetConfigActivity.class);
configIntent.putExtra(AppWidgetManager.EXTRA_APPWI
Problem is that I can't use startActivity() function in AppWidget.
Yes, you can. You are passed in a Context
object into onUpdate()
(or onReceive()
) of your AppWidgetProvider
-- call startActivity()
on that.
// on receive function use this for new activity start
Intent intent = new Intent (context, AppWdget.class);
intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity (intent);
Thanks 2 CommonsWare
There is one more thing to do. context.startActivity();
throws RuntimeException
in this case.
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
So you need to set flag
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
before.