2012-11-06 29 views
0

我的应用程序检查是否启用了GPS,如果没有,它会要求用户启用它。 要lounch设置活动我用下面的代码:当Settings.ACTION_SECURITY_SETTINGS关闭时获取结果

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

但我需要在根据GPS状态我的活动启用或禁用某些控件。我想知道如何在用户关闭设置活动后获得结果。或者也许可以等到设置活动关闭,然后再次检查GPS状态?

回答

1

是的,你可以检查你的onResume()是否启用GPS。

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