안녕하세요
하고자하는 목적이 MainActivity가 활성화 되었을 때만 체크하고 싶으신가요?
아니면 특정 버튼을 눌렀을 때 상태를 체크하고 싶으신가요?
제 생각에는 AsyncTask를 굳이 쓸 필요가 없을 것 같습니다만... 쓰신다고 해도 무방합니다.
아래 코딩을 쓰시고 메니페스트에 퍼미션 주셔서 사용하세요
boolean isGpsEnabled = false;
LocationManager myLocationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
// 시스템 > 설정 > 위치 및 보안 > GPS 위성 사용 여부 체크.
isGpsEnabled = myLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
Log.e("GPS on/off >> ", isGpsEnabled + "");
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
// 디바이스가 블루투스 기능을 지원하는지 체크
if (mBluetoothAdapter == null) {
} else {
Log.e("BlueTooth on/off >> ", mBluetoothAdapter.isEnabled() + "");
}