List of usage examples for android.app AlertDialog setMessage
public void setMessage(CharSequence message)
From source file:com.swetha.easypark.GetIndividualParkingSpotDetails.java
public void updateListView(ArrayList<LinkedHashMap<String, String>> parkingSpotMapList, int success) { if (success == 1) { mSelectedItem = 0;/*from ww w. j a va2s.c o m*/ for (int i = 0; i < parkingSpotMapList.size(); i++) { Log.i("GetIndividualParkingSpotDetails", "Inside For loop"); RadioButtonTracker l_ts; LinkedHashMap<String, String> map = parkingSpotMapList.get(i); Log.i("GetIndividualParkingSpotDetails", "Value in map is " + map.get("vacantspotdisplay")); Log.i("GetIndividualParkingSpotDetails", "parking spoid is is " + map.get("parkingspotid")); if (i == mSelectedItem) { Log.i("GetIndividualParkingSpotDetails", "Before calling RadioButtonTracker constructor - if"); l_ts = new RadioButtonTracker(map, true); Log.i("GetIndividualParkingSpotDetails", "After calling RadioButtonTracker constructor-if"); } else { l_ts = new RadioButtonTracker(map, false); } mSelectionList.add(l_ts); } Log.i("GetIndividualParkingSpotDetails", "After -if-else condition"); adapter = new RadioButtonTrackerListAdapter(mContext); adapter.setListItems(mSelectionList); Log.i("GetIndividualParkingSpotDetails", "After setListItems"); this.setListAdapter(adapter); Log.i("GetIndividualParkingSpotDetails", "After setListAdapter"); } else { AlertDialog alertDialog = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this).create(); // Setting Dialog Title alertDialog.setTitle("Sorry!"); // Setting Dialog Message alertDialog.setMessage("No Parking spots found"); // Setting Icon to Dialog // alertDialog.setIcon(R.drawable.tick); // Setting OK Button alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Intent intent = new Intent(GetIndividualParkingSpotDetails.this, GetParkingLots.class); startActivity(intent); } }); // Showing Alert Message alertDialog.show(); } }
From source file:com.microsoft.band.sdk.heartrate.BandHeartRateAppActivity.java
private void createAlert() { // Make an alert! AlertDialog alertDialog = new AlertDialog.Builder(BandHeartRateAppActivity.this).create(); alertDialog.setTitle("You are stressed!"); alertDialog.setMessage("Comedy has been shown to decrease stress, so watch a video!"); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss();// w w w.ja va2 s . com } }); alertDialog.show(); // End Make an Alert }
From source file:ch.fixme.status.Main.java
@Override protected Dialog onCreateDialog(int id) { AlertDialog dialog = null; switch (id) { case DIALOG_LOADING: dialog = new ProgressDialog(this); dialog.setCancelable(false);/*from w w w . j a v a 2 s .c om*/ dialog.setMessage(getString(R.string.msg_loading)); dialog.setCancelable(true); ((ProgressDialog) dialog).setIndeterminate(true); break; case DIALOG_LIST: return createHsDialog(); } return dialog; }
From source file:ch.bfh.instacircle.NetworkActiveActivity.java
/** * Checks whether the current network configuration is how it is supposed to * be//from www . j a va 2 s . c o m */ public void checkNetworkState() { ConnectivityManager conn = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); SharedPreferences preferences = getSharedPreferences(PREFS_NAME, 0); final String configuredSsid = preferences.getString("SSID", "N/A"); final String password = preferences.getString("password", "N/A"); NetworkInfo nInfo = conn.getNetworkInfo(ConnectivityManager.TYPE_WIFI); String ssid = wifi.getConnectionInfo().getSSID(); Log.d(TAG, "Currently active SSID: " + ssid); // Only check the state if this device is not an access point if (!wifiapmanager.isWifiAPEnabled(wifi)) { Log.d(TAG, "Configured SSID: " + configuredSsid); if (!(nInfo.getDetailedState() == NetworkInfo.DetailedState.CONNECTED && nInfo.getState() == NetworkInfo.State.CONNECTED && ssid.equals(configuredSsid))) { if (repairInitiated == false && repairTime + 6000 < System.currentTimeMillis()) { repairInitiated = true; repairTime = System.currentTimeMillis(); // create a dialog that ask whether you want to repair the // network connection AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("InstaCircle - Network Connection Lost"); alertDialog.setMessage( "The connection to the network " + configuredSsid + " has been lost. Try to repair?"); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Repair", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); adhoc.connectToNetwork(configuredSsid, password, NetworkActiveActivity.this, false); repairInitiated = false; } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Leave", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); WifiManager wifiman = (WifiManager) getSystemService(Context.WIFI_SERVICE); new AdhocWifiManager(wifiman).restoreWifiConfiguration(getBaseContext()); new WifiAPManager().disableHotspot(wifiman, getBaseContext()); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancelAll(); Intent stopIntent = new Intent(NetworkActiveActivity.this, NetworkService.class); stopService(stopIntent); Intent intent = new Intent(NetworkActiveActivity.this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); alertDialog.show(); } } else { repairInitiated = false; } } }
From source file:edu.rutgers.winlab.crowdpp.ui.HomeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.home_fragment_layout, container, false); tb_cal = (ToggleButton) view.findViewById(R.id.tb_home_calibration); tb_service = (ToggleButton) view.findViewById(R.id.tb_home_service); tb_test = (ToggleButton) view.findViewById(R.id.tb_home_test); tv_cal_content = (TextView) view.findViewById(R.id.tv_home_calibration_content); tv_cal_text = (TextView) view.findViewById(R.id.tv_home_calibration_text); tv_debug = (TextView) view.findViewById(R.id.tv_home_test_debug); tv_record = (TextView) view.findViewById(R.id.tv_home_test_record); timer_cal = (Chronometer) view.findViewById(R.id.timer_calibration); timer_test = (Chronometer) view.findViewById(R.id.timer_test); rl_service = (RelativeLayout) view.findViewById(R.id.rl_home_service); rl_test = (RelativeLayout) view.findViewById(R.id.rl_home_test); if (isMyServiceRunning() == true) tb_service.setChecked(true);//from w w w . j a va2 s .c o m if (Constants.calibration()) tv_cal_content.setText("You are all set for the calibration."); if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { Toast.makeText(getActivity(), "Can not find SD card ...", Toast.LENGTH_SHORT).show(); getActivity().finish(); } crowdppDir = new File(Constants.crowdppPath); if (!crowdppDir.exists() || !crowdppDir.isDirectory()) { crowdppDir.mkdir(); } testDir = new File(Constants.testPath); if (!testDir.exists() || !testDir.isDirectory()) { testDir.mkdir(); } calWavFile = crowdppDir + "/" + Constants.PHONE_ID + ".wav"; timer_cal.setVisibility(View.INVISIBLE); timer_test.setVisibility(View.INVISIBLE); mDatabase = new DataBaseHelper(getActivity().getApplicationContext()); mDB = mDatabase.getWritableDatabase(); gps = new LocationTracker(getActivity().getApplicationContext()); s3Client = new AmazonS3Client(new BasicAWSCredentials(Constants.ACCESS_KEY_ID, Constants.SECRET_KEY)); s3Client.setRegion(Region.getRegion(Regions.US_WEST_2)); tb_cal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // prevent the calibration button being pressed when either and test or service is running if (tb_service.isChecked()) { Toast.makeText(getActivity(), "Please turn off the service...", Toast.LENGTH_SHORT).show(); tb_cal.setChecked(false); } else if (tb_test.isChecked()) { Toast.makeText(getActivity(), "Please turn off the test...", Toast.LENGTH_SHORT).show(); tb_cal.setChecked(false); } // calibration else { if (isChecked) { tv_cal_text.setText(Constants.cal_text); rl_service.setVisibility(View.INVISIBLE); rl_test.setVisibility(View.INVISIBLE); timer_cal.setVisibility(View.VISIBLE); AlertDialog dialog = new AlertDialog.Builder(getActivity()).create(); dialog.setTitle("Calibration"); dialog.setMessage(Constants.cal_dialog); dialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { timer_cal.setBase(SystemClock.elapsedRealtime()); timer_cal.start(); tv_cal_content.setText("Recording your voice..."); Bundle mbundle = new Bundle(); mbundle.putString("audiopath", calWavFile); Log.i("HomeFragment", "start audio recording service"); // delete the existing calibration data before the recalibration FileProcess.deleteFile(calWavFile); FileProcess.deleteFile(calWavFile + ".jstk.mfcc.txt"); FileProcess.deleteFile(calWavFile + ".YIN.pitch.txt"); // start audio recording Intent recordIntent = new Intent(getActivity(), AudioRecordService.class); recordIntent.putExtras(mbundle); getActivity().startService(recordIntent); } }); dialog.show(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20); } else { // stop audio recording Intent recordIntent = new Intent(getActivity(), AudioRecordService.class); getActivity().stopService(recordIntent); timer_cal.stop(); tb_cal.setClickable(false); tv_cal_content.setText("Calibrating...."); // start calibration new Calibration().execute(); tb_cal.setClickable(true); tv_cal_text.setText(""); rl_service.setVisibility(View.VISIBLE); rl_test.setVisibility(View.VISIBLE); timer_cal.setVisibility(View.INVISIBLE); } } } }); tb_service.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // prevent the service button being pressed when either and test or calibration is running if (tb_cal.isChecked()) { Toast.makeText(getActivity(), "Please turn off the calibration...", Toast.LENGTH_SHORT).show(); tb_service.setChecked(false); } else if (tb_test.isChecked()) { Toast.makeText(getActivity(), "Please turn off the test...", Toast.LENGTH_SHORT).show(); tb_service.setChecked(false); } // speaker counting service else { Intent countIntent = new Intent(getActivity(), SpeakerCountService.class); if (isChecked) { getActivity().startService(countIntent); } else { getActivity().stopService(countIntent); } } } }); tb_test.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // prevent the test button being pressed when either and service or calibration is running if (tb_cal.isChecked()) { Toast.makeText(getActivity(), "Please turn off the calibration...", Toast.LENGTH_SHORT).show(); tb_test.setChecked(false); } else if (tb_service.isChecked()) { Toast.makeText(getActivity(), "Please turn off the service...", Toast.LENGTH_SHORT).show(); tb_test.setChecked(false); } // perform the speaker counting test else { if (isChecked) { // get location information gps.getLocation(); if (gps.canGetLocation()) { latitude = gps.getLatitude(); longitude = gps.getLongitude(); } else { latitude = -1; longitude = -1; } gps.stopUsingGPS(); timer_test.setBase(SystemClock.elapsedRealtime()); timer_test.start(); tv_debug.setText("Recording..."); testWavFile = testDir + "/" + FileProcess.newFileOnTime("wav"); // start audio recording Bundle mbundle = new Bundle(); mbundle.putString("audiopath", testWavFile); Log.i("HomeFragment", "start audio recording service"); Intent recordIntent = new Intent(getActivity(), AudioRecordService.class); recordIntent.putExtras(mbundle); date = Now.getDate(); start = Now.getTimeOfDay(); getActivity().startService(recordIntent); timer_test.setVisibility(View.VISIBLE); } else { // stop audio recording Intent recordIntent = new Intent(getActivity(), AudioRecordService.class); getActivity().stopService(recordIntent); timer_test.stop(); end = Now.getTimeOfDay(); tb_test.setClickable(false); // start speaker counting test new Test().execute(); timer_test.setVisibility(View.INVISIBLE); tb_test.setClickable(true); } } } }); return view; }
From source file:produvia.com.lights.SmartLightsActivity.java
public void promptLogin(final JSONObject loginService, final JSONObject responseData) { runOnUiThread(new Runnable() { public void run() { try { String type = loginService.getString("type"); //there was a login error. login again if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_NORMAL)) { //prompt for username and password and retry: promptUsernamePassword(loginService, responseData, false, null); } else if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_KEY)) { promptUsernamePassword(loginService, responseData, true, loginService.getString("description")); } else if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_PRESS2LOGIN)) { //prompt for username and password and retry: int countdown = loginService.has("login_timeout") ? loginService.getInt("login_timeout") : 15;/*from w w w . java 2 s . co m*/ final AlertDialog alertDialog = new AlertDialog.Builder(SmartLightsActivity.this).create(); alertDialog.setTitle(loginService.getString("description")); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); alertDialog.setMessage(loginService.getString("description") + "\n" + "Attempting to login again in " + countdown + " seconds..."); alertDialog.show(); // new CountDownTimer(countdown * 1000, 1000) { @Override public void onTick(long millisUntilFinished) { try { alertDialog.setMessage(loginService.getString("description") + "\n" + "Attempting to login again in " + millisUntilFinished / 1000 + " seconds..."); } catch (JSONException e) { } } @Override public void onFinish() { alertDialog.dismiss(); new Thread(new Runnable() { public void run() { try { JSONArray services = new JSONArray(); services.put(loginService); responseData.put("services", services); WeaverSdkApi.servicesSet(SmartLightsActivity.this, responseData); } catch (JSONException e) { } } }).start(); } }.start(); } } catch (JSONException e) { e.printStackTrace(); } } }); }
From source file:com.ushahidi.android.app.ui.phone.AddCheckinActivity.java
/** * Create various dialog/*from w ww .j a va 2 s . c om*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddCheckinActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete checkin deleteCheckins(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:com.google.appinventor.components.runtime.FusiontablesControl.java
private void showNoticeAndDie(String message, String title, String buttonText) { AlertDialog alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle(title);/*from w w w. j av a 2 s . co m*/ // prevents the user from escaping the dialog by hitting the Back button alertDialog.setCancelable(false); alertDialog.setMessage(message); alertDialog.setButton(buttonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { activity.finish(); } }); alertDialog.show(); }
From source file:produvia.com.scanner.DevicesActivity.java
public void promptLogin(final JSONObject loginService, final JSONObject responseData) { runOnUiThread(new Runnable() { public void run() { try { String type = loginService.getString("type"); //there was a login error. login again if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_NORMAL)) { //prompt for username and password and retry: promptUsernamePassword(loginService, responseData, false, null); } else if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_KEY)) { promptUsernamePassword(loginService, responseData, true, loginService.getString("description")); } else if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_PRESS2LOGIN)) { //prompt for username and password and retry: int countdown = loginService.has("login_timeout") ? loginService.getInt("login_timeout") : 15;// w w w . j a va 2 s . com final AlertDialog alertDialog = new AlertDialog.Builder(DevicesActivity.this).create(); alertDialog.setTitle(loginService.getString("description")); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); alertDialog.setMessage(loginService.getString("description") + "\n" + "Attempting to login again in " + countdown + " seconds..."); alertDialog.show(); // new CountDownTimer(countdown * 1000, 1000) { @Override public void onTick(long millisUntilFinished) { try { alertDialog.setMessage(loginService.getString("description") + "\n" + "Attempting to login again in " + millisUntilFinished / 1000 + " seconds..."); } catch (JSONException e) { } } @Override public void onFinish() { alertDialog.dismiss(); new Thread(new Runnable() { public void run() { try { JSONArray services = new JSONArray(); services.put(loginService); responseData.put("services", services); WeaverSdkApi.servicesSet(DevicesActivity.this, responseData); } catch (JSONException e) { } } }).start(); } }.start(); } } catch (JSONException e) { e.printStackTrace(); } } }); }
From source file:com.swetha.easypark.GetIndividualParkingSpotDetails.java
public void displayalertdialog(double latitude, double longitude, String address, int success) { final double lat = latitude; final double lng = longitude; if (success == 1) { final AlertDialog alertDialog = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this).create(); // Setting Dialog Title alertDialog.setTitle("Congratulations!"); // Setting Dialog Message alertDialog.setMessage("Your parking spot has been blocked"); // Setting Icon to Dialog // alertDialog.setIcon(R.drawable.tick); // Setting OK Button alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss();/* ww w. j av a 2s. c om*/ AlertDialog alertDialog1 = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this) .create(); // Setting Dialog Title alertDialog1.setTitle("Do you want to get directions?"); alertDialog1.setButton2("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.e("GetIndividualParkingSpots", "Inside Yes"); Intent yesintent = new Intent(GetIndividualParkingSpotDetails.this, GoogleDirectionsActivity.class); yesintent.putExtra(GetParkingLots.LATITUDE, lat); yesintent.putExtra(GetParkingLots.LONGITUDE, lng); startActivity(yesintent); Log.e("GetIndividualParkingSpots", "After Calling Intent"); } }); alertDialog1.setButton3("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Intent nointent = new Intent(GetIndividualParkingSpotDetails.this, GetParkingLots.class); startActivity(nointent); } }); alertDialog1.show(); } }); // Showing Alert Message alertDialog.show(); if (chk_default.isChecked()) { Log.i("GetIndividualParkingSpotDetails", "Inside Checkbox if "); Log.i("GetIndividualParkingSpotDetails", " Spot has been blocked till long " + toTime); Log.i("GetIndividualParkingSpotDetails", " Spot has been blocked till DateTime" + DateTimeHelpers.convertToTimeFromLong(toTime)); Log.i("GetIndividualParkingSpotDetails", "Inside if checkbox address" + address); scheduleNotification(getNotification( "You parked the car in" + address + "Your parking spot id is " + theParkingSpotName)); } } else { AlertDialog alertDialog = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this).create(); // Setting Dialog Title alertDialog.setTitle("Sorry!"); // Setting Dialog Message alertDialog.setMessage("There was a problem processing your request"); // Setting Icon to Dialog // alertDialog.setIcon(R.drawable.tick); // Setting OK Button alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Intent intent = new Intent(GetIndividualParkingSpotDetails.this, GetParkingLots.class); startActivity(intent); } }); // Showing Alert Message alertDialog.show(); } }