-2

I am using ProgressDialog in one of my android application. its showing me warning as above title. I have used it in java like below. This is not duplicate question. I have searched for solution but have not found it.

    mProgress = new ProgressDialog((this),R.style.AlertDialogTheme);
    mProgress.setCancelable(false);
    mProgress.getWindow().setGravity(Gravity.BOTTOM);
    mProgress.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));

anyone can please suggest me this can cause error or it will not ? how can I solve it ?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

2

Just assert the warning by,

    Window window = mProgress.getWindow();
    assert window != null;
    window.setGravity(Gravity.BOTTOM);
    window.setBackgroundDrawable(new ColorDrawable(Color.WHITE));

or you can wrap it with a if case by

    Window window = mProgress.getWindow();
    if ( window != null )       
       window.setGravity(Gravity.BOTTOM);
       window.setBackgroundDrawable(new ColorDrawable(Color.WHITE));

And its just a lint warning, you can ignore that.

Sanoop Surendran
  • 3,484
  • 4
  • 28
  • 49