在编译时,我得到未处理的异常java.io.IOException
。我已经发布了下面的代码并指出了错误行。我搜索了很多关于这个问题的帖子,但我没有得到任何相关的解决方案。未处理的异常java.io.iOException
MainActivity.java:
public class MainActivity extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
...................
}
public void startRecording() throws IOException {
..................
}
player.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
if (RecordFile != null && ifexist.equals("true")) {
}
else {
if (isRecclicked == true) {
recordButtonPressed = true;
try {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// this code will be executed after 2 seconds
startRecording(); ----> Unhandled Exception java.io.iOException
}
}, 2000);
}
catch (IOException e) {
e.printStackTrace();
}
}
}
}
放码。它的崩溃那边 –
@PreethiRao中的startRecording没有崩溃()method.its编译errror –
@ steve1显示的startRecording()method..if没有必要IOException异常即可。 ..try从抛出异常抛出IOException,或者你可以把IO语句放在try catch块下而不是抛出IOException异常...实际上抛出异常并且不处理活动 –