Example usage for android.app AlertDialog show

List of usage examples for android.app AlertDialog show

Introduction

In this page you can find the example usage for android.app AlertDialog show.

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.aknowledge.v1.automation.RemoteActivity.java

public void showServerAlert() {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Can't Connect to server!");
    alertDialog.setMessage("Check your server details under settings");
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }//from  ww w  . j  a  v  a2  s  .  c  o  m
    });
    // Set the Icon for the Dialog
    alertDialog.show();

}

From source file:com.todoroo.astrid.taskrabbit.TaskRabbitActivity.java

@SuppressWarnings("nls")
private void buildAlertMessageNoGps() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(getString(R.string.tr_alert_gps_title)).setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS),
                            REQUEST_CODE_ENABLE_GPS);
                    showingNoGPSAlertMessage = false;
                }/*from w  ww  .  j  a v  a 2  s. com*/
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    dialog.cancel();
                    showingNoGPSAlertMessage = false;
                    showIntroDialog();
                }
            });
    final AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.otaupdater.SettingsActivity.java

private void showGetProKeyDialog() {
    if (cfg.hasProKey())
        return;/*from w  w w . j av a2s. c  o m*/

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.settings_prokey_title);
    final boolean playServices = Utils.checkPlayServices(this);
    builder.setItems(playServices ? R.array.prokey_ops : R.array.prokey_ops_nomarket,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    which -= playServices ? 1 : 0;
                    switch (which) {
                    case -1:
                        try {
                            Bundle buyIntentBundle = service.getBuyIntent(3, getPackageName(),
                                    Config.PROKEY_SKU, "inapp", null);
                            PendingIntent buyIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                            if (buyIntent != null)
                                startIntentSenderForResult(buyIntent.getIntentSender(), PROKEY_REQ_CODE,
                                        new Intent(), 0, 0, 0);
                        } catch (Exception e) {
                            Toast.makeText(SettingsActivity.this, R.string.prokey_error_init,
                                    Toast.LENGTH_SHORT).show();
                        }
                        break;
                    case 0:
                        redeemProKey();
                        break;
                    //                case 1:
                    //                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Config.SITE_BASE_URL + Config.DONATE_URL)));
                    //                    break;
                    }
                }
            });

    final AlertDialog dlg = builder.create();
    dlg.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            onDialogShown(dlg);
        }
    });
    dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            onDialogClosed(dlg);
        }
    });
    dlg.show();
}

From source file:bikebadger.RideActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.d("Bike Badger", "RideActivity::onCreate");
    super.onCreate(savedInstanceState);

    Context context = getApplicationContext();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    AppManager.AppStartEnum startMode = AppManager.CheckAppStart(getApplicationContext(), preferences);
    //startMode = AppManager.AppStartEnum.EXPIRED_FREE;
    //startMode = AppManager.AppStartEnum.DISABLED;
    switch (startMode) {
    case DISABLED:
        AlertDialog finishAlert = new AlertDialog.Builder(this).create();
        finishAlert.setCancelable(false);
        finishAlert.setTitle("Trial Expired");
        finishAlert.setMessage("Your trial has expired. Please consider purchasing the full version.");
        finishAlert.setButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //RideManager rm = RideManager.get(RideActivity.this);
                //if(rm != null)
                //  rm.Shutdown();
                RideActivity.this.finish();
                //dialog.dismiss();
            }//  w  w w .ja v  a 2  s  . c o  m
        });
        finishAlert.show();
        break;
    case EXPIRED_FREE: // expired trail. Let them purchase or do nothing.
        AppManager.PurchaseDialog(this);
        break;
    case NORMAL_FREE:
        // Still counting down the expiry. Do nothing
        break;
    case NORMAL_PAID:
        // TODO Until I figure out what this overly complicated thing does, don't use it
        // If it is merely to prevent folks from side-loading a copy they somehow get a hold of, they
        // deserve a free version
        //  checkLicense();
        // all is well. Do nothing
        break;
    case FIRST_TIME_FREE:
        // the version number ends in .free
        AppManager.CopyAssetFileOrDir("empty.gpx", context);
        AppManager.CopyAssetFileOrDir("EnchiladaBuffet_Austin.gpx", context);
        AppManager.CopyAssetFileOrDir("BikeBadger.pdf", context);

        // conditional shows the version notes (only if the version has changed)
        VersionNotes myNotes = new VersionNotes(this);
        myNotes.showVersionNotes();
        break;
    case FIRST_TIME_PAID:
        AppManager.CopyAssetFileOrDir("empty.gpx", context);
        AppManager.CopyAssetFileOrDir("EnchiladaBuffet_Austin.gpx", context);
        AppManager.CopyAssetFileOrDir("BikeBadger.pdf", context);

        // TODO Until I figure out what this overly complicated thing does, don't use it
        // If it is merely to prevent folks from side-loading a copy they somehow get a hold of, they
        // deserve a free version
        // checkLicense();

        // conditional shows the version notes (only if the version has changed)
        VersionNotes myNotes2 = new VersionNotes(this);
        myNotes2.showVersionNotes();

        break;
    case FIRST_TIME_VERSION:
        AppManager.CopyAssetFileOrDir("BikeBadger.pdf", context);
        // conditional shows the version notes (only if the version has changed)
        VersionNotes myNotes1 = new VersionNotes(this);
        myNotes1.showVersionNotes();
        break;
    }

    if (AppManager.IsPackageInstalled("net.dinglisch.android.taskerm", context)) {
        Log.d(Constants.APP.TAG, "Tasker Installed");
    }

    if (AppManager.IsPackageInstalled("com.strava", context)) {
        Log.d(Constants.APP.TAG, "Strava Installed");
    } else {
        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("market://details?id=com.google.android.apps.maps"));
        startActivity(intent);
    }

    if (AppManager.IsPackageInstalled("com.maxmpz.audioplayer", context)) {
        Log.d(Constants.APP.TAG, "PowerAMP Installed");
    }

}

From source file:es.uja.photofirma.android.CameraActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.camera_activity);

    logger.appendLog(100, "login usuario satisfactorio");

    //Definicin de elementos visuales involucrados
    lycpt = (ImageView) findViewById(R.id.cameraActivityCameraPhotoTap);
    lyerr = (LinearLayout) findViewById(R.id.cameraActivityErrorHeader);
    lysuc = (LinearLayout) findViewById(R.id.cameraActivitySuccessHeaderTextView);
    lycan = (LinearLayout) findViewById(R.id.cameraActivityCancelHeader);
    lyinf = (LinearLayout) findViewById(R.id.cameraActivityInfoHeader);
    lyupl = (LinearLayout) findViewById(R.id.cameraActivityUploadingHeader);
    lyudone = (LinearLayout) findViewById(R.id.cameraActivitySuccesUploadHeader);
    lyuerr = (LinearLayout) findViewById(R.id.cameraActivityErrorUploadHeader);
    errorText = (TextView) findViewById(R.id.cameraActivityErrorTextView);

    //gestor de servicios de telefonia, para la obtencin del IMEI del terminal
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    if (telephonyManager == null) {
        imeiNumber = getString(R.string.no_imei_available);
    } else {// w  w w .  j  av a2  s.c om
        imeiNumber = telephonyManager.getDeviceId();
    }

    //Deteccin de los parametros necesarios tras un login exitoso
    if (getIntent().hasExtra("userName") && getIntent().hasExtra("userId")
            && getIntent().hasExtra("userEmail")) {
        userName = getIntent().getExtras().getString("userName");
        userId = getIntent().getExtras().getInt("userId");
        userEmail = getIntent().getExtras().getString("userEmail");
    } else {
        Toast.makeText(getApplicationContext(), getString(R.string.no_user_data_found), Toast.LENGTH_LONG)
                .show();
    }

    final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Aviso de privacidad");
    alertDialog.setMessage(getString(R.string.privacy_alert));
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
        }
    });
    alertDialog.show();

    SharedPreferences prefs = getSharedPreferences("prefsfile", Context.MODE_PRIVATE);
    String myPrefServerIp = prefs.getString("prefIpAddress", "10.0.3.2");
    URL_CONTENT_UPLOAD = "https://" + myPrefServerIp + "/photo@firmaServices/content_upload.php";
}

From source file:cm.aptoide.pt.RemoteInSearch.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
    case MANAGE_REPO:
        Intent i = new Intent(this, ManageRepo.class);
        startActivity(i);//  w  ww .j av a 2s  .  c  om
        return true;
    case SEARCH_MENU:
        onSearchRequested();
        return true;
    case ABOUT:
        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.about, null);
        Builder p = new AlertDialog.Builder(this).setView(view);
        final AlertDialog alrt = p.create();
        alrt.setIcon(R.drawable.icon);
        alrt.setTitle("APTOIDE");
        alrt.setButton("ChangeLog", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                Uri uri = Uri.parse("http://aptoide.com/changelog.html");
                startActivity(new Intent(Intent.ACTION_VIEW, uri));
            }
        });
        alrt.show();
        return true;
    case SETTINGS:
        Intent s = new Intent(RemoteInSearch.this, Settings.class);
        s.putExtra("order", order_lst);
        startActivityForResult(s, SETTINGS_FLAG);
    }
    return super.onOptionsItemSelected(item);
}

From source file:nl.nikhef.eduroam.WiFiEduroam.java

private void alert(String title, String message) {
    AlertDialog alertBox = new AlertDialog.Builder(this).create();
    alertBox.setTitle(title);//from ww w  .  j  av  a2s  .  c  om
    alertBox.setMessage(message);
    alertBox.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            onActivityResult(2, RESULT_OK, null);
        }
    });
    alertBox.show();
}

From source file:com.aknowledge.v1.automation.RemoteActivity.java

public void onDevicesLoaded(String result) {
    Log.d("RemoteActivity", "devices loaded: " + result);

    if (dialog != null && dialog.isShowing()) {
        dialog.dismiss();//  ww  w.  j a  v  a2 s  .  c om
    }
    if (result != null) {
        parseMyDevices(result);
        createRemotePanel();
    } else {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle("Problems with your server info.");
        alertDialog.setMessage("You should check your settings and try again.");
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        // Set the Icon for the Dialog
        alertDialog.show();

    }

}

From source file:bander.notepad.NoteListAppCompat.java

/**
 * Delete a note, confirm when preferred.
 *
 * @param context Context to use./* w  w  w  . j a  v  a 2s.c  om*/
 * @param id      ID of the note to delete.
 */
private void deleteNote(Context context, long id) {
    final long noteId = id;
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    boolean deleteConfirmation = preferences.getBoolean("deleteConfirmation", true);
    if (deleteConfirmation) {
        AlertDialog alertDialog = new AlertDialog.Builder(context).setTitle(R.string.dialog_delete)
                .setMessage(R.string.delete_confirmation)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    // OnClickListener
                    public void onClick(DialogInterface dialog, int which) {
                        Uri noteUri = ContentUris.withAppendedId(Note.CONTENT_URI, noteId);
                        getContentResolver().delete(noteUri, null, null);
                    }
                }).setNegativeButton(android.R.string.cancel, null).create();
        alertDialog.show();
    } else {
        Uri noteUri = ContentUris.withAppendedId(Note.CONTENT_URI, noteId);
        getContentResolver().delete(noteUri, null, null);
    }
}

From source file:com.df.app.carsWaiting.CarsWaitingListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cars_waiting);

    swipeListView = (SwipeListView) findViewById(R.id.carsWaitingList);

    data = new ArrayList<CarsWaitingItem>();

    adapter = new CarsWaitingListAdapter(this, data, new CarsWaitingListAdapter.OnAction() {
        @Override//from   www . j ava2 s .c  om
        public void onEditPressed(int position) {
            swipeListView.openAnimate(position);
        }

        @Override
        public void onModifyProcedure(int positon) {
            CarsWaitingItem item = data.get(positon);
            Intent intent = new Intent(CarsWaitingListActivity.this, InputProceduresActivity.class);
            intent.putExtra("carId", item.getCarId());
            startActivity(intent);
        }

        @Override
        public void onDeleteCar(final int position) {
            View view1 = getLayoutInflater().inflate(R.layout.popup_layout, null);
            TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea);
            TextView content = new TextView(view1.getContext());
            content.setText(R.string.confirmDeleteCar);
            content.setTextSize(20f);
            contentArea.addView(content);

            setTextView(view1, R.id.title, getResources().getString(R.string.alert));

            AlertDialog dialog = new AlertDialog.Builder(CarsWaitingListActivity.this).setView(view1)
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            CarsWaitingItem item = data.get(position);
                            deleteCar(item.getCarId());
                        }
                    }).setNegativeButton(R.string.cancel, null).create();

            dialog.show();
        }
    });

    swipeListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() {
        @Override
        public void onClickFrontView(int position) {
            getCarDetail(data.get(position).getCarId(), CarCheckActivity.class);
        }

        @Override
        public void onDismiss(int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                data.remove(position);
            }
            adapter.notifyDataSetChanged();
        }

        @Override
        public void onStartOpen(int position, int action, boolean right) {
            swipeListView.closeOpenedItems();
        }
    });

    swipeListView.setSwipeMode(SwipeListView.SWIPE_MODE_LEFT);
    swipeListView.setSwipeActionLeft(SwipeListView.SWIPE_ACTION_REVEAL);
    swipeListView.setLongClickable(false);
    swipeListView.setSwipeOpenOnLongPress(false);
    swipeListView.setOffsetLeft(620);
    swipeListView.setAnimationTime(300);
    swipeListView.setAdapter(adapter);

    footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.footer, null, false);

    swipeListView.addFooterView(footerView);

    Button homeButton = (Button) findViewById(R.id.buttonHome);
    homeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    Button loadMoreButton = (Button) findViewById(R.id.loadMore);
    loadMoreButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            refresh(false);
        }
    });

    Button refreshButton = (Button) findViewById(R.id.buttonRefresh);
    refreshButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            refresh(true);
        }
    });

    refresh(true);
}