Getting exception in android while enabling Air plane mode after closing the app

Hi All,

I am trying to enable air plane mode just after closing the application (driver.closeapp()), but getting an exeception. Please let me know if anything need to be taken care of to avoid the exception.

Below is the exception:
org.openqa.selenium.WebDriverException: ERROR running Appium command: Cannot read property ‘restart’ of null
at org.openqa.selenium.remote.ErrorHandler.createThrowable(
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at io.appium.java_client.AppiumDriver.execute(

Build info: version: ‘2.46.0’, revision: ‘87c69e2’, time: ‘2015-06-04 16:17:10’
System info: host: ‘nag1-ldl-41649’, ip: ‘’, ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_31’
Driver info:

Can you share your code ?

If it is not necessary to close app you can try putting current running app activity in background [Press Home Button ] and then enable air plane mode.

// Press Home Key

1 Like

Hi Amit,

There is specific requirement to close application first and then enable the air plane mode, this is why we need to automate in same manner.

Steps we are performing:

  1. Setting up the capabilities
  2. Using driver object we close the application - driver.closeapp()
  3. Now we enable air plane mode using below approach.

public void enableAirplaneMode(){
NetworkConnectionSetting connection = new NetworkConnectionSetting(true, false, false);

You could quit the session after closing app ( driver.quit() ) and open a new session which would open , say, phone settings, enable Air plane mode, quit the session, and open a new one with your app and do whatever you plan to do while in Air plane mode.

Appium needs to automate an application.


Appium expects to work with your application. When you call close, things go badly, quickly. See

If you close the app without using the appium call, like we did, things work much better.