error:calling startactivity () from outside of an activity context
This address: Http://blog.csdn.net/caroline_wendy
Android Error: Calling StartActivity () from Outside of an activity context requires the Flag_activity_new_task call local startactivity () , which needs to be in intent set flag is flag_activity_new_task .
startactivity () error, in the method of another class, jump to another interface; such as start the default system settings (setting) interface , you need to pass intent:
Intent i = new Intent (Android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
However, if you start in another class, you need to intent add the FLAG parameter,
flag_activity_new_task;The correct wording is as follows:
public static void Gotolocservicesettings (context context) { final Intent Intent = new Intent ( Android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); Intent.setflags (intent.flag_activity_new_task); Context.startactivity (intent); }
you
will not get an error.
Android-error:calling startactivity () from outside of an activity context