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

data is null at any time #45

Open
ihewro opened this issue Feb 3, 2018 · 3 comments
Open

data is null at any time #45

ihewro opened this issue Feb 3, 2018 · 3 comments

Comments

@ihewro
Copy link

ihewro commented Feb 3, 2018

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            // Great! User has recorded and saved the audio file
            Uri uri = data.getData();
        } else if (resultCode == RESULT_CANCELED) {
            // Oops! User has canceled the recording
        }
    }
}

When the recording is successful, I execute:

            Uri uri = data.getData();

it will occur errors!

this is error details:

ava.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity 
@ihewro
Copy link
Author

ihewro commented Feb 3, 2018

I wonder if this is a bug?

@MahmoudAymann
Copy link

does anyone solved it ?

@ghost
Copy link

ghost commented Jun 26, 2019

I got this issue too.

But that can be solved by using the file defined for saving the record.

Initially, you defined a path like: String filePath = Environment.getExternalStorageDirectory() + "/recorded_audio.wav";

So you can proceed like this:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            // Great! User has recorded and saved the audio file
             String filePath = Environment.getExternalStorageDirectory() + "/recorded_audio.wav";
             Uri uri = Uri.fromFile(new File(filePath));
              //Deal with the Uri now 
        } else if (resultCode == RESULT_CANCELED) {
            // Oops! User has canceled the recording
        }
    }
} 

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