title: Unable to toggle on and off location service using Appium
body: <p>I need to enable and disable location service in Android before my test. I have tried the following solutions but nothing worked at all.</p>
  
  <p>Scenario : 1 
  ADB commands</p>
  
  <p>adb shell settings put secure location_providers_allowed +network,gps
  adb shell settings put secure location_providers_allowed -network,gps</p>
  
  <p>These commands working at times but not all the times so my test fails lot of times for disabling.</p>
  
  <p>Scenario : 2 
  toggleLocationService() Method</p>
  
  <pre><code>public static void enableAndDisableLocation(AppiumDriver&lt;WebElement&gt; driver) {
          ((AndroidDriver&lt;WebElement&gt;) driver).openNotifications();
          ((AndroidDriver&lt;WebElement&gt;) driver).toggleLocationServices();
      }
  </code></pre>
  
  <p>Are there any other solution to enable and disable Location service in Android using Appium. Also I want to know the status of the Location before enabling and disabling.</p>
  
  <p>I am using Java client 5.0.4
  Testing in Android Nougat.</p>