GithubHelp home page GithubHelp logo

android app crush about omrecorder HOT 3 OPEN

boulbaba avatar boulbaba commented on July 21, 2024
android app crush

from omrecorder.

Comments (3)

HarrSolo avatar HarrSolo commented on July 21, 2024

That's because the permission is not obtained to write to the directory
ADD the following code

private void requestPermission() {
ActivityCompat.requestPermissions(MainActivity.this, new
String[]{WRITE_EXTERNAL_STORAGE, RECORD_AUDIO}, RequestPermissionCode);
}

@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case RequestPermissionCode:
            if (grantResults.length > 0) {
                boolean StoragePermission = grantResults[0] ==
                        PackageManager.PERMISSION_GRANTED;
                boolean RecordPermission = grantResults[1] ==
                        PackageManager.PERMISSION_GRANTED;

                if (StoragePermission && RecordPermission) {
                    Toast.makeText(MainActivity.this, "Permission Granted",
                            Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(MainActivity.this, "Permission Denied", Toast.LENGTH_LONG).show();
                }
            }
            break;
    }
}




public boolean checkPermission() {
    int result = ContextCompat.checkSelfPermission(getApplicationContext(),
            WRITE_EXTERNAL_STORAGE);
    int result1 = ContextCompat.checkSelfPermission(getApplicationContext(),
            RECORD_AUDIO);
    return result == PackageManager.PERMISSION_GRANTED &&
            result1 == PackageManager.PERMISSION_GRANTED;
}

and in the onCreate() method add this

if(!checkPermission())
{
requestPermission();
}

DO NOT FORGET to add permission in Manifest.xml too like in the description !

from omrecorder.

gifari98 avatar gifari98 commented on July 21, 2024

@HarrSolo i follow your instruction, but i got an error with the RequestPermissionCode, what actually is that? a variable?
image
it says cannot resolve symbol.

from omrecorder.

HarrSolo avatar HarrSolo commented on July 21, 2024

@HarrSolo i follow your instruction, but i got an error with the RequestPermissionCode, what actually is that? a variable?
image
it says cannot resolve symbol.

Yes its an int.

  • Replace RequestPermissionCode with a number like 99 or
  • add static Integer RequestPermissionCode = 99;

from omrecorder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.