0

以下是我的一段代码:

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 中的异常。但我收到错误异常未报告。

4

2 回答 2

0

如果你想在课堂上处理它,那么从方法中Map抛出并删除块。ExceptionLoadProjectFiletry..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);
}
于 2013-08-23T10:59:31.217 回答
0

修改这个

public void LoadProjectFile(String Filename)

对此:

public void LoadProjectFile(String Filename) throws Exception

try-catch从方法中删除

于 2013-08-23T11:01:53.850 回答