Android examples for Phone:Airplane Mode
close Flight Mode
import android.content.Context; import android.content.Intent; import android.os.Build; import android.provider.Settings; import android.util.Log; public class Main{ /**close Flight Mode*/ public static void closeFlight(Context context) throws Exception { if (Build.VERSION.SDK_INT >= 17) { closeFlightAboveApiLevel17(); } else {//from w ww . j a va 2 s .c o m closeBelowApiLevel17(context); } } private static void closeFlightAboveApiLevel17() throws Exception { try { ShellUtils.sudo("settings", "put", "global", "airplane_mode_on", "0"); ShellUtils.sudo("am", "broadcast", "-a", "android.intent.action.AIRPLANE_MODE", "--ez state", "false"); Log.e("xmg", "sudo success"); } catch (Exception e) { Log.e("xmg", "sudo fail"); ShellUtils.sudo("ndc", "resolver", "flushdefaultif"); } } @SuppressWarnings("deprecation") private static void closeBelowApiLevel17(Context context) throws Exception { Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", false); context.sendBroadcast(intent); } }