Open mr-shitou opened 4 years ago
This code editing should fix
`
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
if (!checkPermissionFromDevice())
requestPermission();
mPreview = findViewById(R.id.surface_view);
captureButton = findViewById(R.id.button_capture);
}
private boolean checkPermissionFromDevice()
{
int write_external_storage_result = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
int camera_result = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
int record_audio_result = ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO);
return write_external_storage_result == PackageManager.PERMISSION_GRANTED
&& camera_result == PackageManager.PERMISSION_GRANTED
&& record_audio_result == PackageManager.PERMISSION_GRANTED;
}
private void requestPermission()
{
ActivityCompat.requestPermissions(
this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO},
REQUEST_PERMISSION_CODE);
}
`
Miss Permission