Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MideaRecord miss permission #59

Open
mr-shitou opened this issue Mar 27, 2020 · 1 comment
Open

MideaRecord miss permission #59

mr-shitou opened this issue Mar 27, 2020 · 1 comment

Comments

@mr-shitou
Copy link

Miss Permission

@diegomazala
Copy link

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);
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants