I'm writing an app which needs to get your location at a certain point.
I used the ionic native geolocation for this which is send to the google API for reverse geocoding.
It works completely like I want it to when I just use ionic serve.
But when I try to run it on android it doesn't seem to work at all.
if I run ionic cordova run android --device -c -l I get these console logs:
[20:23:58] console.log: Device Ready
[20:23:58] console.log: [object Object]
[20:23:58] console.log: No location Error
this is the snippet of code at that page.
constructor(public navCtrl: NavController, public navParams: NavParams, private geo: Geolocation, private platform: Platform, public geocodeProvider: GeocodeProvider) {
this.platform.ready().then(()=>{
console.log("Device Ready");
this.geo.getCurrentPosition(this.options).then(resp =>{
console.log(resp.coords.latitude);
console.log(resp.coords.longitude);
this.getCountry(resp.coords.latitude,resp.coords.longitude);
}).catch((err)=>{
console.log(err)
});
});
}
getCountry(lat,long){
this.geocodeProvider.getCountry(lat,long).subscribe(result =>this.country = this.getName(result));
}
getName(JSON:IRootObject){
var location = JSON.results[0].address_components[0].long_name;
return JSON.results[0].address_components[0].long_name;
}
I can't seem to find out why it isn't working.
EDIT:
My android manifest:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-feature android:name="android.hardware.location" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<application android:hardwareAccelerated="true" android:icon="#mipmap/icon" android:label="#string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="#android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="***" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
</application>
</manifest>
I think you are on Android 6 or above. There you have to request permissions at runtime.
Install:
$ ionic cordova plugin add cordova-plugin-android-permissions
$ npm install --save #ionic-native/android-permissions
Use:
import { AndroidPermissions } from '#ionic-native/android-permissions';
constructor(private androidPermissions: AndroidPermissions) {
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.LOCATION_COURSE)
.then(
result => console.log('Has permission?', result.hasPermission),
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.LOCATION_COURSE)
);
}
You have to do this request for each permission you need.
See https://ionicframework.com/docs/native/android-permissions/ for details.
In the Guidelines by Google you find additional infos how to request permissions and handle the user response (explain why you need the permissions, don't ask to much, ...)
https://developer.android.com/training/permissions/requesting.html
#fastr.de I added this:
constructor(public navCtrl: NavController, public navParams: NavParams, private geo: Geolocation, private platform: Platform, public geocodeProvider: GeocodeProvider,private androidPermissions: AndroidPermissions) {
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.ACCESS_FINE_LOCATION).then(
result => console.log('Has permission? ACCESS_FINE_LOCATION',result.hasPermission),
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.ACCESS_FINE_LOCATION)
);
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.ACCESS_LOCATION_EXTRA_COMMANDS).then(
result => console.log('Has permission? ACCESS_LOCATION_EXTRA_COMMANDS',result.hasPermission),
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.ACCESS_LOCATION_EXTRA_COMMANDS)
);
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.ACCESS_COARSE_LOCATION).then(
result => console.log('Has permission? ACCESS_COARSE_LOCATION',result.hasPermission),
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.ACCESS_COARSE_LOCATION)
);
this.platform.ready().then(()=>{
console.log("Device Ready");
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.ACCESS_COARSE_LOCATION, this.androidPermissions.PERMISSION.ACCESS_FINE_LOCATION,this.androidPermissions.PERMISSION.ACCESS_LOCATION_EXTRA_COMMANDS]);
this.geo.getCurrentPosition(this.options).then(resp =>{
console.log(resp.coords.latitude);
console.log(resp.coords.longitude);
this.getCountry(resp.coords.latitude,resp.coords.longitude);
}).catch((err)=>{
console.log(err)
});
});
}
and the console output is:
[16:17:15] console.log: Device Ready
[16:17:15] console.log: Has permission? ACCESS_LOCATION_EXTRA_COMMANDS true
[16:17:15] console.log: Has permission? ACCESS_FINE_LOCATION true
[16:17:15] console.log: Has permission? ACCESS_COARSE_LOCATION true
[16:17:15] console.log: [object Object]
[16:17:15] console.log: No location Error
Related
My application is closed immediately after launching due permission request without an errors. This is my code, is here something wrong? Also, I post manifest file here to let you check it. I need bluetooth permission and data access.
The probem is in this line:
ActivityCompat.requestPermissions(this, permissions, REQUEST_MICROPHONE);
If I comment this, application will not close after launching.
private static final int REQUEST_MICROPHONE = 1;
private void askPermissions(){
String[] permissions = {Manifest.permission.RECORD_AUDIO,
Manifest.permission.BLUETOOTH,
Manifest.permission.BLUETOOTH_ADMIN,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.BLUETOOTH_SCAN,
Manifest.permission.BLUETOOTH_CONNECT};
if (!hasPermissions(permissions)) {
ActivityCompat.requestPermissions(this, permissions, REQUEST_MICROPHONE);
}
}
private boolean hasPermissions(String[] permissions) {
if(permissions != null){
for(String perm : permissions){
if(ContextCompat.checkSelfPermission(this, perm) != PackageManager.PERMISSION_GRANTED)
return false;
}}
return true;
}
And the Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="30"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<!-- If you want to declare that your app is available to BLE-capable devices only, include the following in your app's manifest:/-->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:configChanges="orientation|screenSize"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:screenOrientation="portrait"
android:theme="#style/Theme.myapp">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.myapp.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
It was discrepancy between Android version and way to get permissions. Unfortunately, it was not any errors or other communications and I have to find a problem by luck.
I'm working with GeckoView and met problem with installing AddOns. As suggested on Documentation, I've provided XPI compatible with Android, but nothing changes. Copying file to Assets doesn't make a change. Browser doesn't acknowledge WebExtension.
private fun setupGeckoView() {
geckoSession?.permissionDelegate = object : GeckoSession.PermissionDelegate {
override fun onContentPermissionRequest(
session: GeckoSession,
perm: GeckoSession.PermissionDelegate.ContentPermission
): GeckoResult<Int>? {
return super.onContentPermissionRequest(session, perm)
}
}
geckoView = findViewById(R.id.geckoView)
val runtime = GeckoRuntime.create(this)
runtime.settings.consoleOutputEnabled = true
runtime.webExtensionController.promptDelegate = PromptListener(runtime.webExtensionController)
runtime.webExtensionController
.install("https://addons.mozilla.org/android/downloads/file/3719055/youtube_high_definition-85.0.0-an+fx.xpi")
geckoSession.open(runtime)
geckoView.setSession(geckoSession)
geckoSession.loadUri("https://www.youtube.com")
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gv.webapp">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.webapp">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--<provider
android:authorities="com.gv.webapp"
android:name="com.gv.webapp.Provider">
<grant-uri-permission android:path="string"
android:pathPattern="string"
android:pathPrefix="string" />
</provider>-->
</application>
</manifest>
I'm checking logs and the result is confusing. I've got prompt that WebExtension is installed, but when I looking at controller.list() it's empty.
You may be missing a PermissionDelegate:
geckoSession?.permissionDelegate = object : GeckoSession.PermissionDelegate {
override fun onContentPermissionRequest(
session: GeckoSession,
perm: GeckoSession.PermissionDelegate.ContentPermission
): GeckoResult<Int>? {
return super.onContentPermissionRequest(session, perm)
}
}
Permission delegate allows you to handle requests from Gecko for any permission that needs handling.
I'm using ionic 1 .
My app is displaying a camera realtime using the Cordova Plugin Camera Preview (9.0.0 (cordova-lib#9.0.1))
I am previewing the apk with this command from my desktop :
ionic cordova run android
My code works really well with a homtom phone using android 5 .
But on my Android 7 Doggee phone, it is displaying a big triangle, I can't even click on it to take a picture .
This is my code :
var videoElement = document.getElementById("video");
var videoSrc = undefined;
navigator.mediaDevices.enumerateDevices()
.then(getDevices).then(getStream).catch(handleError);
function getDevices(deviceInfos) {
for (var i = 0; i !== deviceInfos.length; ++i) {
var deviceInfo = deviceInfos[i];
if (deviceInfo.kind === 'videoinput') {
videoSrc = deviceInfo.deviceId;
break;
}
}
}
function getStream() {
navigator.mediaDevices.getUserMedia({
video: {
deviceId: {
exact: videoSrc
}
}
}).
then(gotStream).catch(handleError);
}
function gotStream(stream) {
videoElement.srcObject = stream;
}
function handleError(error) {
console.log('Error: ', error);
}
And my myproject/platforms/android/app/src/amin/AndroidManifest.xml
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:networkSecurityConfig="#xml/network_security_config" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="#android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.cordovaplugincamerapreview.CameraActivity" android:screenOrientation="portrait" android:theme="#style/CameraPreviewTheme" />
</application>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera2.full" />
<uses-feature android:name="android.hardware.camera2.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.webkit.PermissionRequest" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
</manifest>
Then in my \myproject\platforms\android\app\src\main\res\xml\config.xml
I only have this camera feature :
<feature name="CameraPreview">
<param name="android-package" value="com.cordovaplugincamerapreview.CameraPreview" />
<param name="onload" value="true" />
</feature>
This is the error in the phone console
Error: DOMException: Could not start source
EDIT : Finally solved partially :
I have to go into the settings for the application
and give it access to the camera. I thought that I had permission in the
manifest file, but it didn’t seem to grant it for me.
Scott
Use diagnose plugin to check and ask android permission solved my issue.
checkpermission()
{
this.diagnostic.getPermissionAuthorizationStatus(this.diagnostic.permission.CAMERA)
.then((status) => {
switch(status){
case this.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted to use the camera");
break;
case this.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission to use the camera has not been requested yet");
break;
case this.diagnostic.permissionStatus.DENIED:
console.log("Permission denied to use the camera - ask again?");
break;
case this.diagnostic.permissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied to use the camera - guess we won't be using it then!");
break;
}
})
.catch((error) => {
console.error("The following error occurred: "+error);
});
this.diagnostic.requestRuntimePermission(this.diagnostic.permission.CAMERA)
.then((status) => {
switch(status){
case this.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted to use the camera");
break;
case this.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission to use the camera has not been requested yet");
break;
case this.diagnostic.permissionStatus.DENIED:
console.log("Permission denied to use the camera - ask again?");
break;
case this.diagnostic.permissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied to use the camera - guess we won't be using it then!");
break;
}
})
.catch((error) => {
console.error("The following error occurred: "+error);
});
}
When I run the code below, as soon as the beep sounds to start recording the mic, I get "Network error":
I have no idea what's wrong here. I've:
added the: cordova plugin + npm module correctly,
granted permissions in the app for microphone
tried connected to WIfi
tried connected to 4g
tried removing and re-adding the android platform to the project
tried on 2 different phones (samsung s5 android 6 / sony xperia z5c
android 7)
Here's my basic code, nothing special here:
setupSpeechRecognition() {
this.speechRecognition.requestPermission().then(() => {
this.speechRecognition.startListening().subscribe(
(matches) => {
// matches here...
},
(onerror) => {
alert("Error: " + JSON.stringify(onerror));
}
);
},
() => {}
);
}
And here's my AndroidManifest.xml for kicks:
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="#mipmap/icon" android:label="#string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="#android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="cordova.plugins.Diagnostic$LocationProviderChangedReceiver">
<intent-filter>
<action android:name="android.location.PROVIDERS_CHANGED" />
</intent-filter>
</receiver>
<receiver android:name="cordova.plugins.Diagnostic$NFCStateChangedReceiver">
<intent-filter>
<action android:name="android.nfc.action.ADAPTER_STATE_CHANGED" />
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
Any ideas? Thanks!
I have found a few other questions about this issue but none of the answers have solved it for me. I'm trying to request the fine location permission, but there is no dialog shown. Here's what I'm doing:
int permissionCheck = ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION);
if(permissionCheck == PackageManager.PERMISSION_GRANTED) {
Log.d("Location","Location permission already granted"); // Not logged
// Do other stuff
}
else {
Log.d("Location", "Requesting location permission"); // This is logged
ActivityCompat.requestPermissions(this,
new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_ENABLE_LOCATION);
}
No dialog appears, and onRequestPermissionsResult is not called.
This is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.common" android:installLocation="auto">
<!-- Normal permissions -->
<uses-permission android:name="android.permission.ACCESS_GPS" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" android:required="false" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="com.android.vending.billing.IN_APP_NOTIFY" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- Dangerous permissions -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" android:required="false" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" android:required="false" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" >
</supports-screens>
<application
android:name="com.company.common.App"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name" >
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="AA_DB_NAME" android:value="propertyforce.db" />
<meta-data android:name="AA_DB_VERSION" android:value="11" />
<meta-data android:name="AA_SERIALIZERS"
android:value="com.company.common.utils.db.JSONObjectSerializer,
com.company.common.utils.db.JSONArraySerializer,
com.company.common.utils.db.AddressSerializer" />
<meta-data
android:name="AA_MODELS"
android:value="com.company.common.utils.db.Model" />
<activity
android:name="com.company.common.Name"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_label"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.AnActivity"/>
<!-- Other activities -->
<service
android:name="com.company.common.utils.services.LogDeleter"
android:icon="#drawable/icon"
android:label="Log Deleter" >
</service>
</application>
</manifest>
Here are some tidbits from the gradle file:
compileSdkVersion 23
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 12
targetSdkVersion 23
}
This is in a FragmentActivity, don't know if that matters. I have uninstalled the app and run it so there should be no permissions already accepted. This is on a Nexus 7 running 6.0.
Why not try this library: https://github.com/tajchert/Nammu. It worked for me.
Nammu.askForPermission(activity, String[] permissions, new PermissionCallback() {
#Override
public void permissionGranted() {}
#Override
public void permissionRefused() {}
});
EDIT
I created a library that encapsulates the whole thing and makes it much more easier. It also shows a customisable explanation dialog before the actual request.
Use this library: https://github.com/ayz4sci/permissionHelper
Usage:
To perform an action that requires Android permission, call permissionHelper.verifyPermission. It accepts the following parameters:
String [] - description of each permission required, this will be displayed to the user in the explanation dialog.
String [] - an array of Manifest permissions
PermissionCallback - you put the actions you want to perform when permission is granted or rejected.
See example below:
permissionHelper.verifyPermission(
new String[]{"dial this number", "take picture"},
new String[]{Manifest.permission.CALL_PHONE, Manifest.permission.CAMERA},
new PermissionCallback() {
#Override
public void permissionGranted() {
//action to perform when permission granteed
}
#Override
public void permissionRefused() {
//action to perform when permission refused
}
}
);