//判断热点状态
import android.content.Context;
import android.net.wifi.WifiManager;
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
return wifiManager.isWifiApEnabled();

//判断GPS状态
import android.location.LocationManager;
locationManager = context.getSystemService(context.LOCATION_SERVICE);
boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

//判断NFC状态
import android.nfc.NfcAdapter;
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter();
boolean isEnabled = nfcAdapter != null && nfcAdapter.isEnabled();
return isEnabled;

//数据状态
import android.content.Context;
import android.telephony.TelephonyManager;
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
boolean isDataEnabled = telephonyManager.getDataEnabled();

//蓝牙
import android.bluetooth.BluetoothAdapter;
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
boolean isBluetoothEnabled = bluetoothAdapter.isEnabled();

//WiFi状态
import android.content.Context;
import android.net.wifi.WifiManager;
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
boolean isWifiEnabled = wifiManager.isWifiEnabled();

//是否处于通话中
import android.content.Context;
import android.telephony.TelephonyManager;
telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
int callState = telephonyManager.getCallState();
return callState == TelephonyManager.CALL_STATE_OFFHOOK || callState == TelephonyManager.CALL_STATE_RINGING;

//获取飞行模式状态
import android.provider.Settings;
int airplaneMode = Settings.Global.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
return airplaneMode == 1;

#mvel
 
 
Back to Top