我有一个可以录制声音的应用程序。应用在
代码位:
startActivityForResult(new Intent("android.provider.MediaStore.RECORD_SOUND"), REQUEST_CODE_RECORD);
Logcat:
W/System.err: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.provider.MediaStore.RECORD_SOUND }
W/System.err: at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1944)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1618)
at android.app.Activity.startActivityForResult(Activity.java:4501)
at android.app.Activity.startActivityForResult(Activity.java:4459)
at com.clogica.mp3cutter.activity.RingtoneEditActivity.onCreate(RingtoneEditActivity.java:267)
at android.app.Activity.performCreate(Activity.java:7013)
at android.app.Activity.performCreate(Activity.java:7004)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2734)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
最佳答案
在某些设备上似乎没有录制声音的应用程序。在启动之前,您应该检查是否有录音应用程序。
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(intent, REQUEST_CODE_RECORD);
} else {
Toast.makeText(this, "No sound record application found", Toast.LENGTH_SHORT).show();
}