public class MyWidgetProvider extends AppWidgetProvider {...}
@Override
public void onEnabled (Context contex){
System.out.println("new task flag");
Intent i = new Intent(mainActivity, ReadName.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mainActivity.startActivity(i);
}
I am trying this code to open a new activity before the widget load on the screen but it is not opening a new activity which i want, the message “new task flag” is comming on the LogCat, but not the activity, what is wrong???
Thanks
Assuming ReadName is the name of the Activity class that you want to launch, try using this code instead:
Also, you can’t do system.out.println in android. If you want to print something out, try printing it to the log.