public void root() {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Now What?");
    alertDialog.setCancelable(false);
    alertDialog.setMessage("What do you want to do?");
    alertDialog.setButton(
        "Root",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            try {
              sendBroadcast(
                  new Intent("com.amazon.internal.E_COMMAND").putExtra("cmd", "adbd_start"));
              post();
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });

    alertDialog.setButton3(
        "Exit",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            System.exit(0);
          }
        });
    alertDialog.show();
  }
  /** Create various dialog */
  @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.btn_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.btn_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.btn_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("photo.jpg", IncidentAdd.this));
                  startActivityForResult(intent, REQUEST_CODE_CAMERA);
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_MULTIPLE_CATEGORY:
        {
          return new AlertDialog.Builder(this)
              .setTitle(R.string.add_categories)
              .setMultiChoiceItems(
                  showCategories(),
                  null,
                  new DialogInterface.OnMultiChoiceClickListener() {
                    public void onClick(
                        DialogInterface dialog, int whichButton, boolean isChecked) {
                      // see if categories have previously

                      if (isChecked) {
                        mVectorCategories.add(mCategoriesId.get(whichButton));
                        mError = false;
                      } else {
                        mVectorCategories.remove(mCategoriesId.get(whichButton));
                      }

                      setSelectedCategories(mVectorCategories);
                    }
                  })
              .setPositiveButton(
                  R.string.btn_ok,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                      /* User clicked Yes so do some stuff */
                    }
                  })
              .create();
        }

      case TIME_DIALOG_ID:
        return new TimePickerDialog(
            this,
            mTimeSetListener,
            mCalendar.get(Calendar.HOUR),
            mCalendar.get(Calendar.MINUTE),
            false);

      case DATE_DIALOG_ID:
        return new DatePickerDialog(
            this,
            mDateSetListener,
            mCalendar.get(Calendar.YEAR),
            mCalendar.get(Calendar.MONTH),
            mCalendar.get(Calendar.DAY_OF_MONTH));
    }
    return null;
  }
    // metodo para cuando se toca el area del mapa
    public boolean onTouchEvent(MotionEvent e, MapView m) {

      // si es accion de bajada
      if (e.getAction() == MotionEvent.ACTION_DOWN) {
        start = e.getEventTime();
        x = (int) e.getX();
        y = (int) e.getY();
        touchedPoint =
            map.getProjection()
                .fromPixels(x, y); // se obtine las coordenadas del punto de toque en el mapa
      }
      // si es accion de subida
      if (e.getAction() == MotionEvent.ACTION_UP) {
        stop = e.getEventTime();
      }
      // se calcula la duaracion del click
      if ((stop - start) > 1500) {
        AlertDialog alert =
            new AlertDialog.Builder(MainActivity.this).create(); // se crea un nuevo AlertDialog
        alert.setTitle("Pick an Option");
        alert.setMessage("I told to pick an option");
        // se agregan 3 botones
        alert.setButton(
            "place a pinpoint",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                // se crea un nuevo Overlay para colocar el punto en el mapa
                OverlayItem overlayItem = new OverlayItem(touchedPoint, "what's up", "2nd string");
                // se crea un punto
                CustonPinpoint custom = new CustonPinpoint(d, MainActivity.this);
                // agrega coordenadas
                custom.insertPinpoint(overlayItem);
                // se agrega en las lista de Overlays
                oveList.add(custom);
              }
            });
        alert.setButton2(
            "get addres",
            // debe probarse en el celular
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                String display = "";
                Geocoder geocoder =
                    new Geocoder(
                        getBaseContext(),
                        Locale
                            .getDefault()); // Objeto para transformar una direccion a coordenadas y
                // viseversa
                try {
                  // se obtinen todas las direcciones que se describen en las coordenadas dadas
                  List<Address> addresses =
                      geocoder.getFromLocation(
                          touchedPoint.getLatitudeE6() / 1E6,
                          touchedPoint.getLongitudeE6() / 1E6,
                          1);
                  if (addresses.size() > 0) {
                    for (int i = 0; i < addresses.get(0).getMaxAddressLineIndex(); i++) {
                      display += addresses.get(0).getAddressLine(i) + "\n";
                    }
                    Toast toast = Toast.makeText(getBaseContext(), display, Toast.LENGTH_LONG);
                    toast.show();
                  }
                } catch (Exception e2) {
                  // TODO: handle exception
                  e2.printStackTrace();
                }
              }
            });
        alert.setButton3(
            "Toggle View",
            new DialogInterface.OnClickListener() {
              // cambia entre el mapa satelital y el de calles
              public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                if (map.isSatellite()) {
                  map.setSatellite(false);
                  map.setStreetView(true);
                } else {
                  map.setSatellite(true);
                  map.setStreetView(false);
                }
              }
            });
        alert.show();
        return true;
      }
      return false;
    }
  /** Create various dialog */
  @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, AddReportActivity.this));
                  startActivityForResult(intent, REQUEST_CODE_CAMERA);
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_MULTIPLE_CATEGORY:
        {
          if (showCategories() != null) {
            return new AlertDialog.Builder(this)
                .setTitle(R.string.choose_categories)
                .setMultiChoiceItems(
                    showCategories(),
                    setCheckedCategories(),
                    new DialogInterface.OnMultiChoiceClickListener() {
                      public void onClick(
                          DialogInterface dialog, int whichButton, boolean isChecked) {
                        // see if categories have previously

                        if (isChecked) {
                          mVectorCategories.add(mCategoriesId.get(whichButton));

                          mError = false;
                        } else {
                          mVectorCategories.remove(mCategoriesId.get(whichButton));
                        }

                        setSelectedCategories(mVectorCategories);
                      }
                    })
                .setPositiveButton(
                    R.string.ok,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {

                        /* User clicked Yes so do some stuff */
                      }
                    })
                .create();
          }
        }

      case TIME_DIALOG_ID:
        return new TimePickerDialog(
            this,
            mTimeSetListener,
            mCalendar.get(Calendar.HOUR),
            mCalendar.get(Calendar.MINUTE),
            false);

      case DATE_DIALOG_ID:
        return new DatePickerDialog(
            this,
            mDateSetListener,
            mCalendar.get(Calendar.YEAR),
            mCalendar.get(Calendar.MONTH),
            mCalendar.get(Calendar.DAY_OF_MONTH));

      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) {
                  new DiscardTask(AddReportActivity.this).execute((String) null);
                  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 report
                  deleteReport();
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }
    }
    return null;
  }
  /** Create various dialog */
  @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) {
                  deleteExistingPhoto();
                  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) {
                  deleteExistingPhoto();
                  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) {
                  // delete any existing photo in the pending folder
                  new DiscardTask(AddCheckinActivity.this).execute((String) null);
                  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;
  }