Hi everyone, I am creating an alert dialog box in android by clicking a button. I used the onClick property for XML and the calling function. my code
public void selectPhoneType(View view) { String [] item = {"Home", "Work", "Mobile", "Work Fax", "Home Fax", "Pager", "Other", "Custom"}; AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext()); builder.setTitle("Select Label"); AlertDialog alert = builder.create(); alert.show();}
but this code does not show a warning and gives an error, for example
BadTokenException: Unable to add window -- token null is not for an application.
Please tell me what is wrong with this code.
source share