Alert Dialog on click method not working

view story

http://stackoverflow.com – I have this code for a simple alert dialog which looks like this. Here is my code: private boolean toggle; //an onCreate method here public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.deleteContact: if (selectedContactIndex == -1){ Context context = getApplicationContext(); CharSequence text = "Please select a contact to delete!"; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, text, duration); toast.show(); (HowTos)