kailash09dabhi / OmRecorder

A Simple Pcm / Wav audio recorder with nice api. https://play.google.com/store/apps/details?id=com.kingbull.omrecorder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

android app crush

boulbaba opened this issue · comments

so i have writen a simple code based on your project to record .wav for multiple users but whenever i try the application everything is fine untel i clic on on the imageview containing the photo of mic to record its just crushes ?

any solution ??

this is a link for my question in stackoverflow too https://stackoverflow.com/questions/51821888/record-wav-format-file-in-android-using-omrecorder

plz anwser me asap ??

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 !

@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.

@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;