use of android.content.DialogInterface in project android_frameworks_base by ParanoidAndroid.
the class TrackerActivity method showConfirm.
private void showConfirm(int textId, final Runnable onConfirmAction) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle(R.string.confirm_title);
dialogBuilder.setMessage(textId);
dialogBuilder.setPositiveButton(android.R.string.ok, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
onConfirmAction.run();
}
});
dialogBuilder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
});
dialogBuilder.show();
}
use of android.content.DialogInterface in project android_frameworks_base by ParanoidAndroid.
the class VersionDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Activity activity = getActivity();
// Need to use our library's resources for showing the dialog.
final Context context;
try {
context = activity.createPackageContext(SharedLibraryMain.LIBRARY_PACKAGE, 0);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalStateException("Can't find my package!", e);
}
final Resources res = context.getResources();
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(res.getText(R.string.upgrade_title));
builder.setMessage(res.getString(R.string.upgrade_body, activity.getApplicationInfo().loadLabel(activity.getPackageManager()), context.getApplicationInfo().loadLabel(context.getPackageManager())));
builder.setPositiveButton(res.getText(R.string.upgrade_button), new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Launch play store into the details of our app.
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
} catch (android.content.ActivityNotFoundException anfe) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
}
}
});
return builder.create();
}
use of android.content.DialogInterface in project android_frameworks_base by ParanoidAndroid.
the class BugReportTile method showBugreportDialog.
private void showBugreportDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setPositiveButton(com.android.internal.R.string.report, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
// Add a little delay before executing, to give the
// dialog a chance to go away before it takes a
// screenshot.
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
try {
ActivityManagerNative.getDefault().requestBugReport();
} catch (RemoteException e) {
}
}
}, 500);
}
}
});
builder.setMessage(com.android.internal.R.string.bugreport_message);
builder.setTitle(com.android.internal.R.string.bugreport_title);
builder.setCancelable(true);
final Dialog dialog = builder.create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
try {
WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
} catch (RemoteException e) {
}
dialog.show();
}
use of android.content.DialogInterface in project AndEngine by nicolasgramlich.
the class GenericInputDialogBuilder method create.
// ===========================================================
// Methods
// ===========================================================
public Dialog create() {
final EditText etInput = new EditText(this.mContext);
etInput.setText(this.mDefaultText);
final AlertDialog.Builder ab = new AlertDialog.Builder(this.mContext);
if (this.mTitleResID != 0) {
ab.setTitle(this.mTitleResID);
}
if (this.mMessageResID != 0) {
ab.setMessage(this.mMessageResID);
}
if (this.mIconResID != 0) {
ab.setIcon(this.mIconResID);
}
this.setView(ab, etInput);
ab.setOnCancelListener(this.mOnCancelListener).setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(final DialogInterface pDialog, final int pWhich) {
final T result;
try {
result = GenericInputDialogBuilder.this.generateResult(etInput.getText().toString());
} catch (final IllegalArgumentException e) {
Debug.e("Error in GenericInputDialogBuilder.generateResult()", e);
Toast.makeText(GenericInputDialogBuilder.this.mContext, GenericInputDialogBuilder.this.mErrorResID, Toast.LENGTH_SHORT).show();
return;
}
GenericInputDialogBuilder.this.mSuccessCallback.onCallback(result);
pDialog.dismiss();
}
}).setNegativeButton(android.R.string.cancel, new OnClickListener() {
@Override
public void onClick(final DialogInterface pDialog, final int pWhich) {
GenericInputDialogBuilder.this.mOnCancelListener.onCancel(pDialog);
pDialog.dismiss();
}
});
return ab.create();
}
use of android.content.DialogInterface in project barcodescanner by dm77.
the class FormatSelectorDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (mSelectedIndices == null || mListener == null) {
dismiss();
return null;
}
String[] formats = new String[BarcodeFormat.ALL_FORMATS.size()];
boolean[] checkedIndices = new boolean[BarcodeFormat.ALL_FORMATS.size()];
int i = 0;
for (BarcodeFormat format : BarcodeFormat.ALL_FORMATS) {
formats[i] = format.getName();
if (mSelectedIndices.contains(i)) {
checkedIndices[i] = true;
} else {
checkedIndices[i] = false;
}
i++;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Set the dialog title
builder.setTitle(R.string.choose_formats).setMultiChoiceItems(formats, checkedIndices, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
if (isChecked) {
// If the user checked the item, add it to the selected items
mSelectedIndices.add(which);
} else if (mSelectedIndices.contains(which)) {
// Else, if the item is already in the array, remove it
mSelectedIndices.remove(mSelectedIndices.indexOf(which));
}
}
}).setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// or return them to the component that opened the dialog
if (mListener != null) {
mListener.onFormatsSaved(mSelectedIndices);
}
}
}).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
});
return builder.create();
}
Aggregations