AsyncTask 里的代码不能执行

程序中有一个 AsyncTask 方法,当程序退出之前会被执行。它可以得到当前位置并解析 xml配置文件。当前位置被检索了,但是解析操作未执行。
在 Main Activity 中调用 AsyncTask

   public void quitApplication()
        {       
            FinishProcess fProcess = new FinishProcess();
            fProcess.execute(this);
    }
AsyncTask:
public class FinishProcess extends AsyncTask<Main, Void, Void>
{
    @Override
    protected Void doInBackground(Main... params) {
        LocationHandler lh = new LocationHandler();
        try {
            lh.getLocationSingle(null, params[0]);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        parseXML(params[0]);
        return null;
    }
    private void parseXML(Main params)
    {
        String ANDROID_ID = "android:id";       
        Resources resources = params.getResources();
        try {
            InputStream fXmlFile = resources.openRawResource(R.raw.pages);
            //Reads xml file and gets the node types and attributes
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);
            doc.getDocumentElement().normalize();
            NodeList nList = doc.getElementsByTagName("*");

            for (int temp = 0; temp < nList.getLength(); temp++) {
                Node nNode = nList.item(temp);   
                if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                    Element eElement = (Element) nNode;
                    System.out.println(eElement.getNodeName());
                }
            }
        } 
        catch (Exception e) {
            System.out.println("Catch");
            e.printStackTrace();
        }
    }
}

如果你的应用程序启动完上面这段程序后就退出,那么当主线程在 AsyncTask 运行时,主线程就可能死亡,从而就会孤立它。如果在退出时候需要这样做,就在 Application.onTerminate 线程中运行,不要在 AsyncTask 线程中。

程序都被停止了,你Asynctask就不是程序中的其中一部分??????

建议在Application.onTerminate中,但是该方法不一定被调用,在 AsyncTask写退出代码试一下。