Android and androidadt
Error: Calling startActivity () from outside of an activity context
Address: http://blog.csdn.net/caroline_wendy
Android error: Calling startActivity () from outside of an activity context requires the FLAG_ACTIVITY_NEW_TASKCalls the local
StartActivity (), You need
IntentInternal settings
FlagIs
FLAG_ACTIVITY_NEW_TASK.
Cause: startActivity () is incorrect. In the method of another class, jump to another interface. For example:
Start the default setting Interface, Intent must be passed:
Intent i = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
However, if it is started in another class, Intent needs to add the Flag parameter FLAG_ACTIVITY_NEW_TASK. The correct syntax 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); }
Then
No error reported.