title: How to turn on/off Cellular Network Android?
body: <p>i want to refresh android Cellular Network android, but gets error. i want to make it working.</p>
  
  <p>my code:</p>
  
  <pre><code>Settings.System.putInt(getContentResolver(),
                  Settings.Global.AIRPLANE_MODE_ON, mode ? 1 : 0);// Turning ON/OFF Airplane mode.
  
          Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);// creating intent and Specifying action for AIRPLANE mode.
          intent.putExtra("state", !mode);// indicate the "state" of airplane mode is changed to ON/OFF
          sendBroadcast(intent);// Broadcasting and Intent
  </code></pre>
  
  <p>my manifest file has permission.</p>
  
  <pre><code> &lt;uses-permission android:name="android.permission.WRITE_SETTINGS" /&gt;
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>  FATAL EXCEPTION: main
                                                                         Process: com.zt.refreshnetwork, PID: 20221
                                                                         java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=20221, uid=10237
                                                                             at android.os.Parcel.readException(Parcel.java:1684)
                                                                             at android.os.Parcel.readException(Parcel.java:1637)
                                                                             at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:3537)
                                                                             at android.app.ContextImpl.sendBroadcast(ContextImpl.java:881)
                                                                             at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:421)
                                                                             at com.zt.refreshnetwork.MainActivity.modifyAirplanemode(MainActivity.java:140)
                                                                             at com.zt.refreshnetwork.MainActivity.airPlanemodeON(MainActivity.java:117)
                                                                             at com.zt.refreshnetwork.MainActivity$1.onClick(MainActivity.java:46)
                                                                             at android.view.View.performClick(View.java:5637)
                                                                             at android.view.View$PerformClick.run(View.java:22429)
                                                                             at android.os.Handler.handleCallback(Handler.java:751)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                             at android.os.Looper.loop(Looper.java:154)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
  </code></pre>