Android-PWA-Wrapper
Android-PWA-Wrapper copied to clipboard
Permissions
I added some more permissions to AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
However, the PWA is still not able to use GPS or speech recognition (and it does not specifically ask for these permissions).
When I go to the phone settings and open the app permissions I see that the permissions listed above are known, but not granted:

I have no experience with native app development.
What do I need to do to activate such permissions?
I managed to access the camera and audio adding this codes:
In the MainActivy.java file, add this imports
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import java.util.ArrayList;
import java.util.List;
Then I write this function:
private void checkAndRequestPermissions() {
int cameraPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
int recordPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO);
int audioPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.MODIFY_AUDIO_SETTINGS);
List<String> listPermissionsNeeded = new ArrayList<>();
if (cameraPermission != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.CAMERA);
}
if (recordPermission != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.RECORD_AUDIO);
}
if (audioPermission != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.MODIFY_AUDIO_SETTINGS);
}
if (!listPermissionsNeeded.isEmpty()) {
ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]),1);
}
}
And place this:
checkAndRequestPermissions();
below this:
// Setup App
webViewHelper.setupWebView();
uiManager.changeRecentAppsIcon();
This is to explicitly request these permissions. Which is mandatory from Android 6.0.
And in the AndroidManifest.xml file:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
Sorry for my bad english! I hope helps you