It gives above error because of the Context I was providing to alertdialog builder.
Give:
new AlertDialog.Builder(getParent()).setMessage(“Hello world”).show();
We just need to call getParent() instead of AlertDialog.Builder(this)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…