开发者

Selecting Audio Files Using Intent.createChooser not working with all phones

开发者 https://www.devze.com 2023-02-04 22:38 出处:网络
I am nearing completion of a project I am working on using Android, but ran into a little bump in the road when we got a new device to test our application with.

I am nearing completion of a project I am working on using Android, but ran into a little bump in the road when we got a new device to test our application with.

I am programming using Android 1.6 and my two devices are:

HTC Incredible - Verizon (Android 2.2)

Samsung Galaxy S - T-Mobile (Android 2.1 update 1)

One part of the app开发者_运维百科lication allows the user to select a recorded audio file using:

// Select a recording
i = new Intent();           
i.setAction(Intent.ACTION_GET_CONTENT);
i.setType("audio/*");
startActivityForResult(Intent.createChooser(i, "Select audio file"), Enums.REQUEST_CODE_SELECT_ATTACHMENT);

And will call onActivityResult after the selection is made.

if (resultCode == RESULT_OK && Enums.REQUEST_CODE_SELECT_ATTACHMENT == requestCode)) 
{
    // do something here
}
else
{
    //ResultCode comes back as RESULT_CANCELED
}

This works fine on the device I programmed my original application on (HTC Incredible - Verizon).

However, when using the Samsung Galaxy S (T-Mobile), the first select dialog opens (Music Player | Voice Recorder) but from there nothing really works.

If I select Music Player, none of my recordings are listed (on HTC, I can pick my recordings or music tracks that shipped with my phone).

If I select Voice Recorder, it returns to my onActivityResult method with result code RESULT_CANCELED and displays a toast message saying "Message file limit reached".

Can anyone give some insight on this? Any help will be greatly appreciated!

Thanks!


The Galaxy S audio subsystem is notoriously broken in 2.1. For instance, Skype does not work on these devices. I've found that 2.2 fixes a lot of the issues.

One thing you can experiment with is calling AudioManager.setMode() to MODE_IN_CALL before recording. Also, you might look at some open source code to see if they've solved this particular issue (see for instance Ringdroid).

There's lots of information about how the Galaxy S audio doesn't work according to spec out there (for instance the speakerphone routing is very broken).

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消