ChildOfCode


Maker,Coder,Hacker,Robotic,Open Source. Knowledge Base


Appcelerator Titanium - Android 6.x permission

Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app.

Titanium change some API for this.

Below is how to Request Multiple Permission In Android 6.x We Will Request GPS and External Storage for Our Apps.

Testing Environment

  • Appcelerator Titanium SDK 6.0.1

  • Real Device Android 6.0.1

Note - In Genymotion Simulator some method is work correctly but not in real device especially when request multiple Permission request

//Only Execute this On Android 6.x
    if(this.OSName == "android" && parseInt(this.OSVersion) >= 6)
    {

        var permissionsToRequest = ["android.permission.ACCESS_FINE_LOCATION","android.permission.WRITE_EXTERNAL_STORAGE"];

        if (permissionsToRequest.length > 0) {
            Ti.Android.requestPermissions(permissionsToRequest, function(e) {
                if (e.success) {
                    Ti.API.info("SUCCESS");
                } else {
                    Ti.API.info("ERROR: " + e.error);
                }
            });
        }


    }