Android 当Settings.ACTION\u SECURITY\u Settings关闭时获取结果

Android 当Settings.ACTION\u SECURITY\u Settings关闭时获取结果,android,Android,我的应用程序检查GPS是否启用,如果未启用,请用户启用。 要展开设置活动,我使用以下代码: Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS); startActivity(intent); 但我需要根据GPS状态启用或禁用一些活动控件。我想知道在用户关闭“设置”活动后如何获得结果。或者可以等到“设置”活动关闭后再检查GPS状态 是的,您可以检查您的onResume()中是否启用了GPS @Override public

我的应用程序检查GPS是否启用,如果未启用,请用户启用。 要展开设置活动,我使用以下代码:

Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(intent);

但我需要根据GPS状态启用或禁用一些活动控件。我想知道在用户关闭“设置”活动后如何获得结果。或者可以等到“设置”活动关闭后再检查GPS状态

是的,您可以检查您的
onResume()
中是否启用了GPS

@Override
public void onResume(){
    super.onResume();
    LocationManager manager = (LocationManager) getSystemService(LOCATION_SERVICE);
    if(!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
        // GPS IS NOT ENABLED
    }
}