FOllowing是我的代码:
class GraphicsView extends GLSurfaceView
{
public void LoadProjectFile(String Filename)
{
m_Renderer.m_Project=new Project();
m_Renderer.m_SelectedProjectPath = Filename;
try {
m_Renderer.m_Project.load_file(Filename);
}
catch (Exception e)
{
throw new MalformedURLException();
}
}}
public class Map extends Activity
{
private GraphicsView mGLView;
//private GisGLRenderer m_GisRenderer;
final static String RESULT_KEY="result";
final static int REQ_CODE=1001;
AlertDialog m=null;
public class LoadFile extends AsyncTask<String,String,String>
{
ProgressDialog Asycdialog = new ProgressDialog(Map.this);
@Override
protected void onPreExecute() {
//set message of the dialog
super.onPreExecute();
Asycdialog.setMessage("Loading File");
Asycdialog.setButton(DialogInterface.BUTTON_NEGATIVE,"Cancel",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
//show dialog
if (!Map.this.isFinishing())
{
Asycdialog.show();
}
}
protected void onProgressUpdate(String ... progress)
{
}
protected String doInBackground(String ... Params)
{
try{
Map.this.mGLView.LoadProjectFile(AppFuncs.g_path);
}
catch (Exception e)
{
Toast.makeText(Map.this,"Project file missing please upload project file ",Toast.LENGTH_SHORT).show();
}
Map.this.mGLView.requestRender();
return null;
}
protected void onPostExecute(String result)
{
Asycdialog.dismiss();
super.onPostExecute(result);
}
}
}
我从MAP类调用loadProjectfile函数。我想处理Map类中loadprojectfile中的异常。但是我没有报告错误异常。
答案 0 :(得分:0)
如果你想在Map
课程中处理它,那么从Exception
方法中抛出LoadProjectFile
并删除try..catch
块。
public void LoadProjectFile(String Filename) throws Exception
{
m_Renderer.m_Project=new Project();
m_Renderer.m_SelectedProjectPath = Filename;
m_Renderer.m_Project.load_file(Filename);
}
答案 1 :(得分:0)
修改此
public void LoadProjectFile(String Filename)
到此:
public void LoadProjectFile(String Filename) throws Exception
并从方法中删除try-catch