Question: Environment:

* OS Windows 7
* Appium 1.4.16.1
* Android emulator 6.0

I need to accept any permission alerts(Android 6.0 -- sms,location and etc) automatically.

What I tried:

1. Use `driver.switchTo().alert().accept();`

Result:

`org.openqa.selenium.WebDriverException: Not yet implemented. Please help us: http://appium.io/get-involved.html`
2. Set `capabilities`:

`capabilities.setCapability("autoGrantPermissions", "true");`
`capabilities.setCapability("autoAcceptAlerts", "true");`

Result: it doesn't work

Answer: 
You can give all the required permissions to the app before you launch the app. Below is the list of commands for required permissions. You can execute these commands through your Java code.

```
    adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.READ_EXTERNAL_STORAGE
    adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.WRITE_EXTERNAL_STORAGE
    adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.ACCESS_FINE_LOCATION
    adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.CAMERA
    adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.READ_CONTACTS
    adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.WRITE_CONTACTS

```
try adding capability: 
`'autoGrantPermissions': 'true',`

had the same issue, this solved it for me.