Fix exception with permission

This commit is contained in:
Victor Shcherb 2018-05-25 10:03:37 +02:00
parent b48fcdf0f3
commit 50f9ddbcd5

View file

@ -907,27 +907,26 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} }
} }
public void recordVideo(final double lat, final double lon, final MapActivity mapActivity, final boolean forceExternal) { public void recordVideo(final double lat, final double lon, final MapActivity mapActivity,
final boolean forceExternal) {
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) {
if (AV_EXTERNAL_RECORDER.get() || forceExternal) { if (AV_EXTERNAL_RECORDER.get() || forceExternal) {
captureVideoExternal(lat, lon, mapActivity); captureVideoExternal(lat, lon, mapActivity);
} else { } else {
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO)
== PackageManager.PERMISSION_GRANTED) {
openCamera(); openCamera();
if (cam != null) { if (cam != null) {
initRecMenu(AVActionType.REC_VIDEO, lat, lon); initRecMenu(AVActionType.REC_VIDEO, lat, lon);
recordVideoCamera(lat, lon, mapActivity); recordVideoCamera(lat, lon, mapActivity);
} }
}
} else { } else {
actionLat = lat; actionLat = lat;
actionLon = lon; actionLon = lon;
ActivityCompat.requestPermissions(mapActivity, ActivityCompat.requestPermissions(mapActivity, new String[] { Manifest.permission.CAMERA,
new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO}, Manifest.permission.RECORD_AUDIO }, CAMERA_FOR_VIDEO_REQUEST_CODE);
CAMERA_FOR_VIDEO_REQUEST_CODE);
}
} }
} }
public void recordVideoCamera(final double lat, final double lon, final MapActivity mapActivity) { public void recordVideoCamera(final double lat, final double lon, final MapActivity mapActivity) {