Java 从未调用AsyncTask onPostExecute

Java 从未调用AsyncTask onPostExecute,java,android,android-asynctask,Java,Android,Android Asynctask,我试图添加覆盖注释,但没有使用它 public class Details extends Activity { String name = ""; String balance = ""; public class MyTask extends AsyncTask<Void, Void, String> { ProgressDialog progressDialog; protected void onPreExecute() { progre

我试图添加覆盖注释,但没有使用它

public class Details extends Activity {
String name = "";
String balance = "";

public class MyTask extends AsyncTask<Void, Void, String> {
    ProgressDialog progressDialog;

    protected void onPreExecute() {

        progressDialog = new ProgressDialog(Details.this);
        progressDialog.setMessage("Loading...");
        progressDialog.setCancelable(false);
        progressDialog.show();

    }

    @Override
    protected String doInBackground(Void... arg0) {

NetWork netWork = new NetWork();
SharedPreferences settings = getSharedPreferences("details", 0);
String user = settings.getString("user", "");
String pass = settings.getString("pass", "");

String s="";
try {
    s = netWork.getGradesHtml(
            "https://app.laundro-smart.com/Forms/frmMain.aspx", user, pass,
            "GET",0,3,0,"");
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}


int index = Jsoup
        .parse(s,
                "https://app.laundro-smart.com/Forms/frmMacineStateInRegion.aspx")
        .select("span#ctl00_ContentPlaceHolder1_lblPrePaidBalance")
        .toString().lastIndexOf("<");

 balance =Jsoup.parse(s,
                        "https://app.laundro-smart.com/Forms/frmMacineStateInRegion.aspx")
                        .select("span#ctl00_ContentPlaceHolder1_lblPrePaidBalance")
                        .toString().substring(55, index);
index = Jsoup
        .parse(s,
                "https://app.laundro-smart.com/Forms/frmMacineStateInRegion.aspx")
        .select("span#ctl00_lnkUsername").toString()
        .lastIndexOf("<");
name= Jsoup.parse(s,
                        "https://app.laundro-smart.com/Forms/frmMacineStateInRegion.aspx")
                        .select("span#ctl00_lnkUsername")
                        .toString().substring(58, index);
                        return name;    
    }
    @Override
    protected void onPostExecute(String aa) {

        TextView a = (TextView) findViewById(R.id.textView2);
        a.setText(aa);
        a =(TextView)findViewById(R.id.textView5);
        a.setText(balance);
        progressDialog.cancel();

    }

}

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_details);
    (new MyTask()).execute();           


}

我有一个示例代码,您可以编辑并尝试此代码。此代码用于从internet下载文件,下载完成后将转到其他活动 公共类asyncDownloader扩展了AsyncTask{


它应该会崩溃,或者你的应用程序可能会崩溃,你需要提供更多详细信息。你看到进度条了吗?是的,我看到了进度条,并且应用程序没有崩溃,进度对话框将永远加载。然后检查doInbackground部分。你的异步任务将执行。
    @Override
    protected void onPostExecute(String result) {
        // TODO Auto-generated method stub

        String path=Environment
                .getExternalStorageDirectory().getPath() + "/SimonSong.mp3";
        Log.e("simon", "Path is "+path);
        Intent intent = new Intent();
        intent.setAction(Constants.BROAD);
        intent.putExtra("test", path);
        sendBroadcast(intent);

        super.onPostExecute(result);
    }

    @Override
    protected String doInBackground(String... params) {
        // TODO Auto-generated method stub
        // Toast.makeText(this, "async class is called",
        // Toast.LENGTH_LONG).show();
        Log.e("simon", "async class is called");
        int count;
        try {
            URL url = new URL(params[0]);
            URLConnection conection = url.openConnection();
            conection.connect();

            int lenghtOfFile = conection.getContentLength();
            Log.e("simon", "download is started");
            InputStream input = new BufferedInputStream(url.openStream(),
                    10 * 1024);

            OutputStream output = new FileOutputStream(Environment
                    .getExternalStorageDirectory().getPath() + "/SimonSong.mp3");
            byte data[] = new byte[1024];
            long total = 0;
            Prog pg = new Prog();
            while ((count = input.read(data)) != -1) {
                total += count;

                int temp = (int) ((total * 100) / lenghtOfFile);                
                //Log.e("simon", "Downloading completed " + temp + " %");
                output.write(data, 0, count);
                pg.setUpdate(temp);
            }

            output.flush();
            output.close();
            input.close();




            //Log.e("simon", "download is finished");

        } catch (Exception e) {
            Log.e("Error: ", e.getMessage());
        }

        return null;
    }

    @Override
    protected void onProgressUpdate(String... values) {
        // TODO Auto-generated method stub
        super.onProgressUpdate(values);
        //Log.e("simon","Value  :  "+values[0]);
    }


}