안드로이드에서 맵관련 액티비티를 만들다보면 GPS정보를 가져와야 할때가 많은데 현재 GPS정보를 가져올 수 있는지 여부를 확인하기 위해서는 아래와 같이 사용하면 된다.
String context = Context.LOCATION_SERVICE; LocationManager locationManager = (LocationManager)getSystemService(context); boolean b =locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
마지막 열의 boolean값으로 GPS사용가능 여부를 반환한다.
GPS정보사용할수 없을때 사용자를 바로 GPS설정화면으로 보내기 위해서는 아래와 같이 인텐트를 호출 하면 된다.
Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SETTINGS); startActivity(intent);
