Asynchronous 做后台工作

Asynchronous 做后台工作,asynchronous,exception-handling,media-player,runtime-error,Asynchronous,Exception Handling,Media Player,Runtime Error,我正在尝试加载Mediaplayer的动态URL。如何处理各种异常,如执行期间出现的文件未找到和超时异常 public class MediaAsynchTask extends AsyncTask<String, Void, Object> { protected void onPreExecute() { super.onPreExecute(); progress = new ProgressDialog(AudioView.this); progress.setMessage

我正在尝试加载Mediaplayer的动态URL。如何处理各种异常,如执行期间出现的文件未找到和超时异常

public class MediaAsynchTask extends AsyncTask<String, Void, Object> {
protected void onPreExecute() {
super.onPreExecute();
progress = new ProgressDialog(AudioView.this);
progress.setMessage("LOADING........");
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progress.setCancelable(true);
progress.show();
}
protected void onPostExecute(Object result) {
super.onPostExecute(result);
if(result!=null){
progress.dismiss();
}else{
Audio.this.finish();
}
}
Protected Object doInBackground(String... params) {
try {
if (!true) 
{
MediaPlayer m = MediaPlayer.create(Audio.this,Uri.parse("audiourl.mp3"));
myProgressBar.setMax(mMediaPlayer.getDuration());
}return mMediaPlayer;
}catch (Exception e) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(),"Check Your NetWork and Data Connection",Toast.LENGTH_LONG).show();
}
});
} 
return mMediaPlayer;
}
}
公共类MediaAsynchTask扩展了AsyncTask{
受保护的void onPreExecute(){
super.onPreExecute();
进度=新建进度对话框(AudioView.this);
progress.setMessage(“加载…”);
progress.setProgressStyle(ProgressDialog.STYLE\u微调器);
进度。可设置可取消(true);
progress.show();
}
受保护的void onPostExecute(对象结果){
super.onPostExecute(结果);
如果(结果!=null){
进步。解散();
}否则{
Audio.this.finish();
}
}
受保护对象doInBackground(字符串…参数){
试一试{
如果(!true)
{
MediaPlayer m=MediaPlayer.create(Audio.this,Uri.parse(“audiourl.mp3”);
myProgressBar.setMax(mmediplayer.getDuration());
}返回层;
}捕获(例外e){
runOnUiThread(新的Runnable(){
公开募捐{
Toast.makeText(getApplicationContext(),“检查网络和数据连接”,Toast.LENGTH_LONG.show();
}
});
} 
返回层;
}
}

非常简单,您可以这样做:

try{
 **//your code goes here**
}catch(FileNotFoundException exception){
//handle exception
}//**handle other possible exceptions**
catch(JsonParseException exception){
    exception.printStackTrace();
}catch(JsonProcessingException exception){
    exception.printStackTrace();
}

谢谢,但是目标异常和合子力接近如何处理请帮助我