我只是有时一个错误,说活动com.prueba.omnibus.EspacialTecnico渗漏最初这里
这种情况发生在活动完成和一个AsyncTask的功能被执行。我已经搜查,但我不知道什么问题可以。
I have only sometimes an error which says Activity com.prueba.omnibus.EspacialTecnico has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41e794a0 that was originally added here
This happens when the activity finishes and an asynctask function is executed. I have searched but I have no idea what the problem could be.
操作,当用户点击完成的错误发生是DOEN。
Action that is doen when the user clicks "finish" and the error happens.
protected Dialog onCreateDialog(int id) {
super.onCreateDialog(id);
switch (id) {
case (int) DIALOG_ALERT_SALIR:
return new AlertDialog.Builder(this)
.setIcon(R.drawable.icon_warning)
.setTitle(R.string.warning)
.setMessage(R.string.confsalir)
.setPositiveButton(R.string.alert_dialog_ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
if (batteryReceiver == null){
}
else{
try{
unregisterReceiver(batteryReceiver);
}catch(IllegalArgumentException iae){
}
batteryReceiver = null;
}
Correccion();
Parseo();
reloj.cancel();
if (Titulacion.IsReachable1(getApplicationContext())){
new CreateResultados().execute();
}
EspacialTecnico.this.finish();
try {
XMLResumen.escribirXMLResume();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}
})
.setNegativeButton(R.string.alert_dialog_cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
}
})
.create();
}
return null;
}
AsyncTask的功能 请问错误的对话框中产生的?
Asynctask Function Could the error be produced by the dialog?
class CreateResultados extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(EspacialTecnico.this);
pDialog.setMessage("Transfiriendo...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
protected String doInBackground(String... args) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", Ident.getDNI()));
params.add(new BasicNameValuePair("nombre", Nombres.getNombre()));
params.add(new BasicNameValuePair("tablet", Nombres.Tablet()));
params.add(new BasicNameValuePair("fecha", Titulacion.fecha()));
params.add(new BasicNameValuePair("test", nombre));
params.add(new BasicNameValuePair("correctas", correctasString));
params.add(new BasicNameValuePair("errores", fallosString));
params.add(new BasicNameValuePair("PC", PC));
JSONObject json = jsonParser.makeHttpRequest(url_crear_resultados,
"POST", params);
Log.d("Create Response", json.toString());
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
} else {
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}
这有什么坏呢?感谢您的帮助
Is there anything "bad" done? Thanks for the help
这个异常通常来自对话框仍处于活动状态时,活动结束。
This exception usually comes from dialogs that are still active when the activity is finishing.
在在preExecute()
创建一个新的对话框,但它可能是这样 pDialog
已持有参考活性对话框。周围的一些方式:
In onPreExecute()
you create a new dialog but it might be so that pDialog
already holds a reference to an active dialog. Some ways around it:
创建一个新的前检查 pDialog == NULL
。驳回后分配空
到 pDialog
。
如果 pDialog!= NULL
,辞退()
它首先创建一个新的对话框之前。
If pDialog != null
, dismiss()
it first before creating a new dialog.
(另 super.onCreateDialog()
是不必要的,因为你没有做与返回对话框
东西。 )
(Also super.onCreateDialog()
is unnecessary as you're not doing anything with the returned Dialog
.)