MediaStore.Audio.Media.RECORD_SOUND_ACTION无法在设备上运行:三星和LG

时间:2011-09-12 09:46:22

标签: android

Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
((Activity) context).startActivityForResult(intent, requestCode);

和onActivityRezult:

Uri uri;
            if (requestCode == REQUEST_CODE_ATTACH_SOUND) {
                uri = (Uri) data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
                if (Settings.System.DEFAULT_RINGTONE_URI.equals(uri)) {
                    uri = null;
                }
            } else {
                uri = data.getData();
            }

在模拟器上,htc工作正常。但是在三星和LG不能正常工作的情况下,RECORD应用程序什有什么问题?

1 个答案:

答案 0 :(得分:3)

我也不确定你是如何或为何使用Extra铃声......

试试这个,打电话给录音机,这个例子的代码是1 ......

public void RecordAudio(View view)
{
    Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
    startActivityForResult(intent, 1); // intent and requestCode of 1

}

要接收音频,请使用

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{     if (requestCode == 1) {
        // is the resultCode OK?
      if (resultCode == RESULT_OK) {
              // lets get the uri
            Uri audioUri = data.getData();

            Toast.makeText(getBaseContext(), "Reply from Recorder", Toast.LENGTH_SHORT).show();
              // lets do something with it.
              // functiontodsomethingAudio(audioUri);
          }
      }

它对我有用......我在一本书中找到了代码,它不是我的!