未处理的异常java.io.iOException
我在编译时收到未处理的异常未处理的异常java.io.iOException,java,android,ioexception,Java,Android,Ioexception,我在编译时收到未处理的异常java.io.IOException。我已经发布了下面的代码,并指出了错误行。我搜索了很多关于这个问题的帖子,但没有找到任何相关的解决方案 MainActivity.java: public class MainActivity extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInsta
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();
}
}
}
}
您调用了
startRecording()
,我假设它可以抛出一个IOException
,但是您没有指定IOException
可以发生在public void run()
中。如果用try-catch块包围startRecording()
,则应该修复此问题。调用startRecording()
,我假设它可以抛出IOException
,但您没有指定IOException
可以发生在public void run()
内部。如果用try-catch块包围startRecording()
,则应该修复此问题。放置startRecording的代码。。它崩溃了there@PreethiRaostartRecording()方法中没有崩溃。它的编译errror@steve1显示开始记录()方法..如果不需要IOException,那么…尝试从抛出IOException中删除,或者您可以将IO语句置于try catch块下,而不是抛出IOException…实际上,u抛出异常,而不是在startRecording的@User404put代码发布的activitytry解决方案中处理。。它崩溃了there@PreethiRaostartRecording()方法中没有崩溃。它的编译errror@steve1显示开始记录()方法..如果不需要IOException,那么…尝试从抛出IOException中删除,或者您可以将IO语句置于try catch块下,而不是抛出IOException…实际上,u抛出异常,而不是@User404发布的activitytry解决方案中的句柄
try {
startRecording();
}catch(IOException ex) {
//Do something with the exception
}