java - How can one detect airplane mode on Android? -
i have code in application detects if wi-fi actively connected. code triggers runtimeexception if airplane mode enabled. display separate error message when in mode anyway. how can reliably detect if android device in airplane mode?
/** * gets state of airplane mode. * * @param context * @return true if enabled. */ private static boolean isairplanemodeon(context context) { return settings.system.getint(context.getcontentresolver(), settings.system.airplane_mode_on, 0) != 0; }
Comments
Post a Comment