我正在使用asynctask的exlend在preexicute中我呼吁进行progressdialog而在postexicure中我使用dismiss。当我尝试运行应用程序时,应用程序会继续收集。
public class DownloadText extends AsyncTask<String,String,String> {
TextView tv;
ImageView home,guest;
Context context;
private ProgressDialog progressDialog;
public DownloadText(TextView tv,Context context) {
this.tv=tv;
this.context=context;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog=new ProgressDialog(context);
progressDialog.setMessage("loading...");
progressDialog.setCancelable(false);
progressDialog.show();
}
@Override
protected String doInBackground(String... strings) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Document document= null;
Elements score;
try {
document = Jsoup.connect(strings[1]).get();
} catch (IOException e) {
e.printStackTrace();
}
score=document.select(strings[0]);
return score.text();
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
tv.setText(s);
progressDialog.dismiss();
}
@Override
protected void onCancelled() {
progressDialog.dismiss();
super.onCancelled();
}
}
E / WindowManager:android.view.WindowLeaked:Activity com.example.aviv.project1.SummeyAct泄漏了窗口 com.android.internal.policy.PhoneWindow $ DecorView {f838863 V.E ...... R ...... D 0,0-1248,348}最初是在这里添加的 在android.view.ViewRootImpl。(ViewRootImpl.java:469) 在android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:309) 在android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85) 在android.app.Dialog.show(Dialog.java:328) 在com.example.aviv.project1.DownloadText.onPreExecute(DownloadText.java:46) 在android.os.AsyncTask.executeOnExecutor(AsyncTask.java:604) 在android.os.AsyncTask.execute(AsyncTask.java:551) 在com.example.aviv.project1.BoxScoreFragment $ 2 $ 1.run(BoxScoreFragment.java:107) 在android.os.Handler.handleCallback(Handler.java:815) 在android.os.Handler.dispatchMessage(Handler.java:104) 在android.os.Looper.loop(Looper.java:207) 在android.app.ActivityThread.main(ActivityThread.java:5811) at java.lang.reflect.Method.invoke(Native Method) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:907) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768)