Android activate gps with AlertDialog: how to wait for the user to take action?

后端 未结 5 764
春和景丽
春和景丽 2020-12-17 20:18

I\'ve read different posts that there is no way to wait for the user to take an action when an AlertDialog is shown because it blocks the UI.

However,

5条回答
  •  醉梦人生
    2020-12-17 21:05

    I done that by using simple function but without displaying an alert box i redirected usercontrol to setting page

    Here is the function i used

    public void isGPSEnable(){
            LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
            boolean enabled = service
              .isProviderEnabled(LocationManager.GPS_PROVIDER);
            if (!enabled) {
              Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
              startActivity(intent);
            } 
    
    }
    

提交回复
热议问题