简体   繁体   English

如何以编程方式为Android手机调用默认录音机应用程序?

[英]how to call the default voice recorder app programmatically for android phone?

i'm trying to create an app that allows voice recording. 我正在尝试创建一个允许录音的应用程序。 i hope to call the default voice recorder app just like how i call the camera app. 我希望像我打电话给相机应用程序一样调用默认的录音机应用程序。 what i wanted is my app will intent/call the default app. 我想要的是我的应用程序将意图/调用默认应用程序。 after recording, it will return immediately to my app (just like what happen when i call for the camera) 录音后,它会立即返回我的应用程序(就像我打电话给相机时发生的那样)

the code that i used for calling the camera : 我用来调用相机的代码:

Intent takePictureFromCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

is there anyway that is close to the code above, where its simple and also achieved what i wanted ? 无论如何,这是接近上面的代码,它的简单,也实现了我想要的?

Try this, 尝试这个,

Intent recordIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(recordIntent, RESULT_OK);

And onActivityResult 和onActivityResult

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
  if (resultCode == Activity.RESULT_OK)
  {
    String theFilePath = data.getData().toString();
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM