即使在处理窗口泄漏异常后也不会显示警报

时间:2015-08-19 16:40:32

标签: android

我尝试修复窗口泄漏问题,查看其他帖子,其中我添加了onPause并关闭了警告框,即使错误消失了,我看不到我的警报框,我有以下自定义警报类。

private class AsyncCallWS extends AsyncTask<String, Void, Void> {

    @Override
    protected Void doInBackground(String... params) {
        // get user data from session
         HashMap<String, String> user = session.getUserDetails();
        // name
          String Id = user.get(SessionManagement.KEY_ID);
           reminderList = WebService.invokeGetReminderWS("GetReminder", Integer.parseInt(Id));
           for(int i=0;i<reminderList.size();i++) {
             accept=WebService.approveInvoiceExeedDiscountLimit(reminderList.get(i).getPrmR_Id(), buttonVal, commentVal);
           }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        //not able to show the alert
        if(accept) {
            if(alert!=null) {
                alert.showAlertDialog(ItemActivity.this, "Accepted", "Invoice Accepted", true);
            }
            Intent intent = new Intent(getApplicationContext(), ReminderActivity.class);
            intent.putExtra("reminderList", (java.io.Serializable) reminderList);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }else{
           alert.showAlertDialog(ItemActivity.this, "Rejected", "Invoice Rejected", false);

        }
    }
}
@Override
public void onPause() {
    super.onPause();
    if(alert != null){
        alert.dismiss();
        alert=null;
    }
}

和我的警报类

public class AlertDialogManager {
     AlertDialog alertDialog;
    public void showAlertDialog(Context context, String title, String message,
            Boolean status) {
         alertDialog = new AlertDialog.Builder(context).create();

        // Setting Dialog Title
        alertDialog.setTitle(title);

        // Setting Dialog Message
        alertDialog.setMessage(message);

        if(status != null)
            // Setting alert dialog icon
            alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);

        // Setting OK Button
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                alertDialog.cancel();
            }
        });

        // Showing Alert Message
        alertDialog.show();
    }

    public void dismiss(){
         alertDialog.dismiss();
    }
}

我需要在接受时以及在其他地方显示警报..,在我获得窗口泄露异常之前,我处理了添加onPause()。但是没有显示警报。我在onCreate()中初始化了警报。

0 个答案:

没有答案