问题描述:

I'm checking the gps provider status and if it's disable I show an AlertDialog. I want to automatically dismiss this AlertDialog when gps provider status change to enabled.

I made check in onResume() and everything is good except if the user change the location settings by the quick settings drop down - then onResume() is not called.

onWindowFocusChanged() is not being called either.

网友答案:

try this code...

public class getLocation implements
    LocationListener {

 @Override
public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();


}


@Override
public void onLocationChanged(Location loc) {


}

@Override
public void onProviderDisabled(String provider) {

}

@Override
public void onProviderEnabled(String provider) {

 if(provider.equalsIgnoreCase("gps"))
    {
        dialog.dismiss();
    }

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {

}

Hope this Code Helps You...

相关阅读:
Top