Java Code Examples for android.app.AlertDialog

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project agit, under directory /agit/src/main/java/com/madgag/agit/prompts/.

Source file: DialogPromptUIBehaviour.java

  18 
vote

public void onPrepareDialog(int id,Dialog dialog){
  AlertDialog alertDialog=(AlertDialog)dialog;
switch (id) {
case YES_NO_DIALOG:
    updateWithCurrentNotification(alertDialog);
  break;
case STRING_ENTRY_DIALOG:
updateWithCurrentNotification(alertDialog);
input.setText("");
break;
default :
}
}
 

Example 2

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/adapter/.

Source file: StreamAdapter.java

  18 
vote

private void confirmDeletingSession(final ButtonsActivity context){
  AlertDialog.Builder b=new AlertDialog.Builder(context);
  b.setMessage("This is the only stream, delete session?").setCancelable(true).setPositiveButton("Yes",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      sessionManager.deleteSession();
      Intents.triggerSync(context);
      Intents.sessions(context,context);
    }
  }
).setNegativeButton("No",NoOp.dialogOnClick());
  AlertDialog dialog=b.create();
  dialog.show();
}
 

Example 3

From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/.

Source file: NewsActivity.java

  18 
vote

@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (resultCode == RESULT_OK) {
    AlertDialog.Builder builder=new AlertDialog.Builder(this);
    builder.setMessage(R.string.report_detail_new_report_ok).setCancelable(false).setPositiveButton("Ok",new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int id){
        NewsActivity.this.finish();
        NewsActivity.this.overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
      }
    }
);
    AlertDialog alert=builder.create();
    alert.show();
  }
}
 

Example 4

From project Android, under directory /app/src/main/java/com/github/mobile/ui/.

Source file: ConfirmDialogFragment.java

  18 
vote

public Dialog onCreateDialog(final Bundle savedInstanceState){
  AlertDialog dialog=LightAlertDialog.create(getActivity());
  dialog.setTitle(getTitle());
  dialog.setMessage(getMessage());
  dialog.setButton(BUTTON_POSITIVE,getResources().getString(android.R.string.yes),this);
  dialog.setButton(BUTTON_NEGATIVE,getResources().getString(android.R.string.no),this);
  dialog.setCancelable(true);
  dialog.setOnCancelListener(this);
  return dialog;
}
 

Example 5

From project android-joedayz, under directory /Proyectos/TaxiLab1/src/com/mycompany/.

Source file: Alerts.java

  18 
vote

public static void ShowErrorInicioSesion(Context con){
  AlertDialog.Builder builder=new AlertDialog.Builder(con);
  builder.setTitle("Inicio de Sesion");
  builder.setIcon(android.R.drawable.ic_dialog_info);
  DialogListener listner=new DialogListener();
  builder.setMessage("Inicio de Sesion fallido");
  builder.setPositiveButton("ok",listner);
  AlertDialog diag=builder.create();
  diag.show();
}
 

Example 6

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/deprecated/.

Source file: VoiceProxy.java

  18 
vote

@Override public AlertDialog create(){
  final AlertDialog dialog=super.create();
  dialog.setOnShowListener(new DialogInterface.OnShowListener(){
    @Override public void onShow(    DialogInterface dialogInterface){
      TextView textView=(TextView)mAlertDialog.findViewById(android.R.id.message);
      if (textView != null) {
        textView.setMovementMethod(LinkMovementMethod.getInstance());
      }
    }
  }
);
  mAlertDialog=dialog;
  return dialog;
}
 

Example 7

From project androidtracks, under directory /src/org/sfcta/cycletracks/.

Source file: MainInput.java

  18 
vote

private void showWelcomeDialog(){
  final AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setMessage("Please enter your personal details so we can learn a bit about you.\n\nThen, try to use CycleTracks every time you ride. Your trip routes will be sent to the SFCTA so we can plan for better biking!\n\nThanks,\nThe SFCTA CycleTracks team").setCancelable(false).setTitle("Welcome to CycleTracks!").setPositiveButton("OK",new DialogInterface.OnClickListener(){
    public void onClick(    final DialogInterface dialog,    final int id){
      startActivity(new Intent(MainInput.this,UserInfoActivity.class));
    }
  }
);
  final AlertDialog alert=builder.create();
  alert.show();
}
 

Example 8

From project 2Degrees-Toolbox, under directory /Toolbox/src/biz/shadowservices/DegreesToolbox/.

Source file: MainActivity.java

  17 
vote

private void valuePackMenuNodeView(final PackTreeNode node){
  if (node instanceof PackTreeLeaf) {
    askToSend((PackTreeLeaf)node);
    return;
  }
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(node.getQuestionText());
  builder.setItems(node.getChildrenCharSequence(),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int item){
      PackTreeNode selectedNode=node.getAt(item);
      valuePackMenuNodeView(selectedNode);
    }
  }
);
  AlertDialog alert=builder.create();
  alert.show();
}
 

Example 9

From project Airports, under directory /src/com/nadmm/airports/aeronav/.

Source file: DtppActivity.java

  17 
vote

protected void checkDelete(){
  AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
  builder.setMessage("Delete all downloaded charts for this airport?").setPositiveButton("Yes",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int id){
      deleteCharts();
    }
  }
).setNegativeButton("No",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int id){
    }
  }
);
  AlertDialog alert=builder.create();
  alert.show();
}
 

Example 10

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.

Source file: PhotoSyncActivity.java

  17 
vote

/** 
 * Returns  {@link View.OnClickListener} for "Add" button. When the button is clicked application determines whether it runs onthe emulator or the actual device and based on that knowledge takes a photo from its resources or using phones camera.
 */
private View.OnClickListener getOnAddClickListener(){
  return new View.OnClickListener(){
    @Override public void onClick(    final View v){
      CharSequence[] items={"Camera","Photo gallery","Random image"};
      final boolean isEmulator="google_sdk".equals(Build.PRODUCT) || "sdk".equals(Build.PRODUCT);
      if (isEmulator) {
        items=new CharSequence[]{"Photo gallery","Random image"};
      }
      AlertDialog.Builder builder=new AlertDialog.Builder(v.getContext());
      builder.setTitle("Choose source:");
      builder.setItems(items,new DialogInterface.OnClickListener(){
        @Override public void onClick(        final DialogInterface dialog,        final int item){
          if (isEmulator) {
            if (item == 0) {
              getImageFromGallery();
            }
 else {
              getRandomImage();
            }
          }
 else {
            if (item == 0) {
              getImageFromCamera();
            }
 else             if (item == 1) {
              getImageFromGallery();
            }
 else {
              getRandomImage();
            }
          }
        }
      }
);
      AlertDialog alert=builder.create();
      alert.show();
    }
  }
;
}
 

Example 11

From project android-bankdroid, under directory /src/com/liato/bankdroid/.

Source file: BankEditActivity.java

  17 
vote

protected void onPostExecute(final Void unused){
  AutoRefreshService.sendWidgetRefresh(context);
  if (this.dialog.isShowing()) {
    this.dialog.dismiss();
  }
  if (this.exc != null) {
    AlertDialog.Builder builder=new AlertDialog.Builder(context);
    if (this.exc instanceof BankChoiceException) {
      final BankChoiceException e=(BankChoiceException)exc;
      final String[] items=new String[e.getBanks().size()];
      int i=0;
      for (      BankChoice b : e.getBanks()) {
        items[i]=b.getName();
        i++;
      }
      builder.setTitle(R.string.select_a_bank);
      builder.setItems(items,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int item){
          SELECTED_BANK.setExtras(e.getBanks().get(item).getId());
          new DataRetrieverTask(context,SELECTED_BANK).execute();
        }
      }
);
    }
 else {
      builder.setMessage(this.exc.getMessage()).setTitle(res.getText(R.string.could_not_create_account)).setIcon(android.R.drawable.ic_dialog_alert).setNeutralButton("Ok",new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int id){
          dialog.cancel();
        }
      }
);
    }
    AlertDialog alert=builder.create();
    alert.show();
  }
 else {
    context.finish();
  }
}
 

Example 12

From project Android-File-Manager, under directory /src/com/nexes/manager/.

Source file: EventHandler.java

  17 
vote

/** 
 * This private method is used to display options the user can select when the tool box button is pressed. The WIFI option is commented out as it doesn't seem to fit with the overall idea of the application. However to display it, just  uncomment the below code and the code in the AndroidManifest.xml file.
 */
private void display_dialog(int type){
  AlertDialog.Builder builder;
  AlertDialog dialog;
switch (type) {
case MANAGE_DIALOG:
    CharSequence[] options={"Process Info","Application backup"};
  builder=new AlertDialog.Builder(mContext);
builder.setTitle("Tool Box");
builder.setIcon(R.drawable.toolbox);
builder.setItems(options,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int index){
Intent i;
switch (index) {
case 0:
  i=new Intent(mContext,ProcessManager.class);
mContext.startActivity(i);
break;
case 1:
i=new Intent(mContext,ApplicationBackup.class);
mContext.startActivity(i);
break;
}
}
}
);
dialog=builder.create();
dialog.show();
break;
}
}
 

Example 13

From project android-flash-cards, under directory /src/org/thomasamsler/android/flashcards/fragment/.

Source file: CardSetsFragment.java

  17 
vote

private void deleteCardSet(final int listItemPosition){
  AlertDialog.Builder builder=new AlertDialog.Builder(mActivity);
  builder.setMessage(R.string.delete_card_set_dialog_message);
  builder.setCancelable(false);
  builder.setPositiveButton(R.string.delete_card_set_dialog_ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      CardSet cardSet=mCardSets.get(listItemPosition);
      List<CardSet> cardSets=mDataSource.getCardSets();
      if (cardSets.contains(cardSet)) {
        mDataSource.deleteCardSet(cardSet);
      }
      mCardSets.remove(listItemPosition);
      Collections.sort(mCardSets);
      mArrayAdapter.notifyDataSetChanged();
    }
  }
);
  builder.setNegativeButton(R.string.delete_card_set_dialog_cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      dialog.cancel();
    }
  }
);
  AlertDialog alert=builder.create();
  alert.show();
}
 

Example 14

From project Android-Flashcards, under directory /src/com/secretsockssoftware/androidflashcards/.

Source file: AndroidFlashcards.java

  17 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case DELETE_ID:
    AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  final LessonListItem lesson_item=lessons[(int)info.id];
AlertDialog alertDialog=new AlertDialog.Builder(me).create();
alertDialog.setTitle("Confirm Delete");
if (lesson_item.isDir) alertDialog.setMessage("Are you sure you want to delete:\n" + lesson_item.name + "\n\nAll lessons in the directory will be deleted");
 else alertDialog.setMessage("Are you sure you want to delete the lesson:\n" + lesson_item.name);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,"OK",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
File f=new File(lesson_item.file);
if (lesson_item.isDir) {
deleteDir(f);
}
 else {
if (f.exists()) f.delete();
f=new File(lesson_item.source);
if (f.exists()) f.delete();
}
parseLessons();
}
}
);
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,"Cancel",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
}
}
);
alertDialog.show();
return true;
}
return super.onContextItemSelected(item);
}
 

Example 15

From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/.

Source file: GatherFramesActivity.java

  17 
vote

private void handleTakePhotoClick(){
  if (mFrameAdapter.getCount() >= this.getResources().getInteger(R.integer.max_frames)) {
    if (!this.mInFrameLimitDialog) {
      this.mInFrameLimitDialog=true;
      AlertDialog d=DialogHelper.getErrorDialog(this,null,this.getResources().getString(R.string.error_max_frames));
      d.setOnDismissListener(new OnDismissListener(){
        @Override public void onDismiss(        DialogInterface dialog){
          mInFrameLimitDialog=false;
        }
      }
);
      d.show();
    }
  }
 else {
    this.mCameraSurface.startCapture();
  }
}
 

Example 16

From project android-rackspacecloud, under directory /src/com/rackspacecloud/android/.

Source file: CloudActivity.java

  17 
vote

protected final void showAlert(String title,String message){
  try {
    AlertDialog alert=new AlertDialog.Builder(this).create();
    alert.setTitle(title);
    alert.setMessage(message);
    alert.setButton("OK",new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        return;
      }
    }
);
    alert.show();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 17

From project android-voip-service, under directory /src/main/java/org/linphone/.

Source file: AbstractContactPickerActivity.java

  17 
vote

protected void choosePhoneNumberAndDial(final CharSequence contactName,final String id){
  List<String> phones=extractPhones(id);
  phones.addAll(extractSipNumbers(id));
switch (phones.size()) {
case 0:
    String msg=String.format(getString(R.string.no_phone_numbers),contactName);
  Toast.makeText(this,msg,Toast.LENGTH_LONG).show();
break;
case 1:
returnSelectedValues(phones.get(0),contactName.toString(),getPhotoUri(id));
break;
default :
AlertDialog.Builder builder=new AlertDialog.Builder(this);
final ArrayAdapter<String> pAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,phones);
builder.setTitle(String.format(getString(R.string.title_numbers_dialog),contactName));
builder.setAdapter(pAdapter,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
returnSelectedValues(pAdapter.getItem(which),contactName.toString(),getPhotoUri(id));
}
}
);
builder.setCancelable(true);
builder.setNeutralButton("cancel",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
dialog.dismiss();
}
}
);
AlertDialog dialog=builder.create();
dialog.show();
}
}
 

Example 18

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/controller/.

Source file: AbstractController.java

  17 
vote

protected void showDialog(final AlertDialog.Builder builder){
  builder.setCancelable(true);
  builder.setNegativeButton("Close",new OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      dialog.cancel();
      mDialogShowing=false;
    }
  }
);
  mActivity.runOnUiThread(new Runnable(){
    public void run(){
      final AlertDialog alert=builder.create();
      try {
        if (!mDialogShowing) {
          alert.show();
          mDialogShowing=true;
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
);
}
 

Example 19

From project androidquery, under directory /src/com/androidquery/auth/.

Source file: GoogleHandle.java

  17 
vote

private void accountDialog(){
  AlertDialog.Builder builder=new AlertDialog.Builder(act);
  accs=am.getAccountsByType("com.google");
  int size=accs.length;
  if (size == 1) {
    auth(accs[0]);
  }
 else {
    String[] names=new String[size];
    for (int i=0; i < size; i++) {
      names[i]=accs[i].name;
    }
    builder.setItems(names,this);
    builder.setOnCancelListener(this);
    AlertDialog dialog=builder.create();
    new AQuery(act).show(dialog);
  }
}
 

Example 20

From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.

Source file: TiledMapActivity.java

  17 
vote

@Override public boolean onShortPress(final int row,final int column,final boolean isEmpty){
  if (isEmpty) {
    LayoutInflater li=getLayoutInflater();
    TileSelectViewOnItemClickListener listener=new TileSelectViewOnItemClickListener();
    GridView grid=(GridView)li.inflate(R.layout.select_grid,null);
    grid.setAdapter(adapter);
    grid.setOnItemClickListener(listener);
    AlertDialog.Builder builder=new AlertDialog.Builder(TiledMapActivity.this);
    builder.setView(grid);
    AlertDialog dialog=builder.create();
    listener.setDialog(dialog);
    listener.setView(view);
    listener.setRow(row);
    listener.setColumn(column);
    dialog.show();
  }
 else {
    view.rotateTile(row,column);
  }
  return true;
}
 

Example 21

From project android_7, under directory /src/org/immopoly/android/app/.

Source file: UserDataManager.java

  17 
vote

protected void showExposeDialog(final Flat flat,final Result result,final String title){
  AlertDialog.Builder builder=new AlertDialog.Builder(activity);
  builder.setTitle(title);
  final String text=null != result.history ? result.history.getText() : (null != result.exception ? result.exception.getMessage() : "Ein Fehler ist aufgetreten.");
  builder.setMessage(text);
  builder.setCancelable(true).setNegativeButton(activity.getString(R.string.share_item),new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int id){
      Settings.getFlatLink(Integer.toString(flat.uid),false);
      Settings.shareMessage(activity,title,text,Settings.getFlatLink(Integer.toString(flat.uid),false));
      mTracker.trackEvent(TrackingManager.CATEGORY_ALERT_EXPOSE_TAKEN,TrackingManager.ACTION_SHARE,TrackingManager.LABEL_POSITIVE,0);
    }
  }
);
  builder.setPositiveButton(result.success ? R.string.button_ok : R.string.button_mist,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int id){
      mTracker.trackEvent(TrackingManager.CATEGORY_ALERT_EXPOSE_TAKEN,TrackingManager.ACTION_SHARE,TrackingManager.LABEL_NEGATIVE,0);
    }
  }
);
  AlertDialog alert=builder.create();
  alert.show();
}
 

Example 22

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: AccessibilitySettings.java

  17 
vote

/** 
 * Handles the change of the accessibility enabled setting state.
 * @param preference The preference for enabling/disabling accessibility.
 */
private void handleEnableAccessibilityStateChange(CheckBoxPreference preference){
  if (preference.isChecked()) {
    Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,1);
    setAccessibilityServicePreferencesState(true);
  }
 else {
    final CheckBoxPreference checkBoxPreference=preference;
    AlertDialog dialog=(new AlertDialog.Builder(this)).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(getString(R.string.accessibility_service_disable_warning)).setCancelable(true).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
        setAccessibilityServicePreferencesState(false);
      }
    }
).setNegativeButton(android.R.string.cancel,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        checkBoxPreference.setChecked(true);
      }
    }
).create();
    dialog.show();
  }
}
 

Example 23

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: BoardView.java

  15 
vote

@Override public void win(byte side){
  final String sideString=(side == Side.BLACK) ? r.getString(R.string.black) : r.getString(R.string.white);
  parent.runOnUiThread(new Runnable(){
    @Override public void run(){
      new AlertDialog.Builder(getContext()).setMessage(sideString + " " + r.getString(R.string.wins)).setTitle(r.getString(R.string.game_over)).setCancelable(false).setNeutralButton("Ok",null).show();
    }
  }
);
}
 

Example 24

From project ActionBarSherlock, under directory /samples/fragments/src/com/actionbarsherlock/sample/fragments/.

Source file: FragmentAlertDialogSupport.java

  15 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  int title=getArguments().getInt("title");
  return new AlertDialog.Builder(getActivity()).setIcon(R.drawable.alert_dialog_icon).setTitle(title).setPositiveButton(R.string.alert_dialog_ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      ((FragmentAlertDialogSupport)getActivity()).doPositiveClick();
    }
  }
).setNegativeButton(R.string.alert_dialog_cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      ((FragmentAlertDialogSupport)getActivity()).doNegativeClick();
    }
  }
).create();
}
 

Example 25

From project AlarmApp-Android, under directory /src/org/alarmapp/activities/map/.

Source file: MarkerOverlay.java

  15 
vote

@Override protected boolean onTap(int index){
  OverlayItem item=items.get(index);
  AlertDialog.Builder dialog=new AlertDialog.Builder(this.context);
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet());
  dialog.show();
  return true;
}
 

Example 26

From project alljoyn_java, under directory /samples/android/secure/logonclient/src/org/alljoyn/bus/samples/logonclient/.

Source file: Client.java

  15 
vote

@Override protected Dialog onCreateDialog(int id){
switch (id) {
case DIALOG_LOGON:
    LayoutInflater factory=LayoutInflater.from(this);
  final View view=factory.inflate(R.layout.logon_dialog,null);
return new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.logon_dialog).setCancelable(false).setView(view).setPositiveButton(R.string.dialog_ok,new DialogInterface.OnClickListener(){
  public void onClick(  DialogInterface dialog,  int id){
    mUserName=((EditText)view.findViewById(R.id.UserNameEditText)).getText().toString();
    mPassword=((EditText)view.findViewById(R.id.PasswordEditText)).getText().toString();
    mLatch.countDown();
  }
}
).create();
default :
return null;
}
}
 

Example 27

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/app/.

Source file: AmenoidApp.java

  15 
vote

@Override public void onCreate(){
  this.cache=new SimpleWebImageCache<ThumbnailBus,ThumbnailMessage>(null,null,101,bus);
  Config.init(getApplicationContext());
  DEVELOPER_MODE=getResources().getBoolean(R.bool.debuggable);
  if (getResources().getBoolean(R.bool.strict)) {
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyDropBox().penaltyLog().build());
  }
  super.onCreate();
  prefs=PreferenceManager.getDefaultSharedPreferences(this);
  amenTypeThin=Typeface.createFromAsset(getAssets(),"fonts/AmenTypeThin.ttf");
  amenTypeBold=Typeface.createFromAsset(getAssets(),"fonts/AmenTypeBold.ttf");
  instance=this;
  builder=new AlertDialog.Builder(this);
  Log.v(TAG,"onCreate");
  final String authToken=readAuthTokenFromPrefs(prefs);
  final User me=readMeFromPrefs(prefs);
  String email=prefs.getString(Constants.PREFS_EMAIL,null);
  if (TextUtils.isEmpty(email)) {
    email=prefs.getString(Constants.PREFS_USER_NAME,"");
    if (!TextUtils.isEmpty(email) && email.contains("@")) {
      SharedPreferences.Editor editor=prefs.edit();
      editor.putString(Constants.PREFS_EMAIL,email);
      editor.commit();
    }
  }
  final String password=prefs.getString(Constants.PREFS_PASSWORD,null);
  if (authToken != null && me != null) {
    configureAmenService();
    service.init(authToken,me);
  }
 else   if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) {
    getService(email,password);
  }
 else {
    getService();
  }
}
 

Example 28

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/base/.

Source file: Dialogs.java

  15 
vote

public void showMsg(final String msg,final boolean isCancelable,final Callback okayCallback){
  Log.d(TAG,"showErrorMesage message:" + msg);
  try {
    final Activity activity=CurrentActivityHolder.getInstance().getCurrentActivity();
    if (activity != null) {
      activity.runOnUiThread(new Runnable(){
        @Override public void run(){
          AlertDialog.Builder dlgBuilder=new AlertDialog.Builder(activity).setMessage(msg).setCancelable(isCancelable).setPositiveButton(R.string.okay,new DialogInterface.OnClickListener(){
            public void onClick(            DialogInterface dialog,            int buttonId){
              okayCallback.okay();
            }
          }
);
          if (isCancelable) {
            dlgBuilder.setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
              public void onClick(              DialogInterface dialog,              int buttonId){
              }
            }
);
          }
          dlgBuilder.show();
        }
      }
);
    }
 else {
      Toast.makeText(BibleApplication.getApplication().getApplicationContext(),msg,Toast.LENGTH_LONG).show();
    }
  }
 catch (  Exception e) {
    Log.e(TAG,"Error showing error message.  Original error msg:" + msg,e);
  }
}
 

Example 29

From project andlytics, under directory /src/com/github/andlyticsproject/.

Source file: ExportActivity.java

  15 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  final String filename=getArguments().getString(ARG_FILENAME);
  return new AlertDialog.Builder(getActivity()).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.export_confirm_dialog_title).setMessage(getResources().getString(R.string.export_confirm_dialog_message,filename)).setPositiveButton(android.R.string.yes,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      ((ExportActivity)getActivity()).startExport();
    }
  }
).setNegativeButton(android.R.string.no,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      dismiss();
    }
  }
).create();
}
 

Example 30

From project Android-automation, under directory /TmtsApp/src/com/taobao/tmts/framework/app/.

Source file: MainActivity.java

  15 
vote

private void createDialog(){
  Builder dialog=new AlertDialog.Builder(this);
  dialog.setTitle("AlartDialog");
  dialog.setPositiveButton("OK",new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      Toast.makeText(MainActivity.this,"OK",Toast.LENGTH_SHORT);
    }
  }
);
  dialog.setNegativeButton("Cancel",new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      Toast.makeText(MainActivity.this,"Cancel",Toast.LENGTH_SHORT);
    }
  }
);
  dialog.create();
  dialog.show();
}
 

Example 31

From project android-client, under directory /xwiki-android-client/src/org/xwiki/android/client/dev/.

Source file: QuickTest.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.quicktest);
  AlertDialog.Builder alertbox=new AlertDialog.Builder(this);
  alertbox.setMessage("Only a code testing/exploration activity.remove this from production");
  alertbox.setNeutralButton("Ok",new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface arg0,    int arg1){
    }
  }
);
  alertbox.show();
  Comment c1, c2, c3, c4;
  Document doc=new Document("xwiki","Blog","tempTestPage");
  doc.setTitle("tempTestPage");
  c1=new Comment("0");
  c2=new Comment("1");
  c3=new Comment("2");
  c3.setId(2);
  c4=new Comment("3");
  c4.setId(3);
  c1.addReplyComment(c2);
  c3.addReplyComment(c4);
  doc.addComment(c1,true);
  doc.setComment(c3);
  doc.setComment(c4);
  DocumentRao rao=XWikiApplicationContext.getInstance().newRESTfulManager().newDocumentRao();
  try {
    rao.delete(doc);
    rao.create(doc);
  }
 catch (  RestConnectionException e) {
    e.printStackTrace();
  }
catch (  RaoException e) {
    e.printStackTrace();
  }
}
 

Example 32

From project android-client_2, under directory /src/org/mifos/androidclient/util/ui/.

Source file: UIUtils.java

  15 
vote

/** 
 * Displays a simple dialog which prompts user for text input. The user can either commit the input or cancel the dialog.
 * @param labelText the label to be used for the dialog
 * @param callbacks the callbacks to be invoked when user interacts with the input
 * @return input provided by the user, or null value if the dialog was canceled
 */
public void promptForTextInput(String labelText,String defaultValue,final DialogCallbacks callbacks){
  final AlertDialog.Builder builder=new AlertDialog.Builder(mContext);
  final View dialogView=mLayoutInflater.inflate(R.layout.text_input_dialog,null);
  final TextView dialogLabel=(TextView)dialogView.findViewById(R.id.dialogLabel);
  dialogLabel.setText(labelText);
  final EditText textInput=(EditText)dialogView.findViewById(R.id.dialogInput);
  textInput.setText(defaultValue);
  builder.setView(dialogView).setPositiveButton(mContext.getText(R.string.dialog_ok),new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      callbacks.onCommit(textInput.getText().toString().trim());
    }
  }
).setNegativeButton(mContext.getText(R.string.dialog_cancel),new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      callbacks.onCancel();
      dialogInterface.cancel();
    }
  }
).setOnCancelListener(new DialogInterface.OnCancelListener(){
    @Override public void onCancel(    DialogInterface dialogInterface){
      callbacks.onCancel();
    }
  }
).show();
}
 

Example 33

From project android-context, under directory /defunct/.

Source file: ContextBrowserActivity.java

  15 
vote

private void add(){
  LayoutInflater inflater=LayoutInflater.from(this);
  View addView=inflater.inflate(R.layout.add_edit,null);
  final DialogWrapper wrapper=new DialogWrapper(addView);
  new AlertDialog.Builder(this).setTitle(R.string.add_context).setView(addView).setPositiveButton(R.string.ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      processAdd(wrapper);
    }
  }
).setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
    }
  }
).show();
}
 

Example 34

From project android-donations-lib, under directory /org_donations/src/org/donations/.

Source file: DonationsActivity.java

  15 
vote

@Override public void onRequestPurchaseResponse(RequestPurchase request,ResponseCode responseCode){
  Log.d(DonationsUtils.TAG,request.mProductId + ": " + responseCode);
  if (responseCode == ResponseCode.RESULT_OK) {
    Log.d(DonationsUtils.TAG,"purchase was successfully sent to server");
    AlertDialog.Builder dialog=new AlertDialog.Builder(DonationsActivity.this);
    dialog.setIcon(android.R.drawable.ic_dialog_info);
    dialog.setTitle(R.string.donations__thanks_dialog_title);
    dialog.setMessage(R.string.donations__thanks_dialog);
    dialog.setCancelable(true);
    dialog.setNeutralButton(R.string.donations__button_close,new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        dialog.dismiss();
      }
    }
);
    dialog.show();
  }
 else   if (responseCode == ResponseCode.RESULT_USER_CANCELED) {
    Log.d(DonationsUtils.TAG,"user canceled purchase");
  }
 else {
    Log.d(DonationsUtils.TAG,"purchase failed");
  }
}
 

Example 35

From project Android-FFXIEQ, under directory /ffxieq/src/com/github/kanata3249/ffxieq/android/.

Source file: EquipmentSetEditActivity.java

  15 
vote

@Override protected Dialog onCreateDialog(int id){
  Dialog dialog;
  AlertDialog.Builder builder;
switch (id) {
case R.string.EquipmentNotFound:
    builder=new AlertDialog.Builder(this);
  builder.setCancelable(true);
builder.setMessage(getString(R.string.EquipmentNotFound));
builder.setTitle(getString(R.string.app_name));
builder.setPositiveButton(R.string.OK,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
dismissDialog(R.string.EquipmentNotFound);
FragmentManager fm=getSupportFragmentManager();
EquipmentSetEditFragment fragment=(EquipmentSetEditFragment)fm.findFragmentById(R.id.CharacterEdit);
if (fragment != null) fragment.startReselect();
}
}
);
builder.setNegativeButton(R.string.Cancel,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
dismissDialog(R.string.EquipmentNotFound);
FragmentManager fm=getSupportFragmentManager();
EquipmentSetEditFragment fragment=(EquipmentSetEditFragment)fm.findFragmentById(R.id.CharacterEdit);
if (fragment != null) fragment.cancelReselect();
}
}
);
dialog=builder.create();
return dialog;
}
return super.onCreateDialog(id);
}
 

Example 36

From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.

Source file: BluetoothActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setTheme(android.R.style.Theme_Holo_Dialog_MinWidth);
  setContentView(R.layout.bluetooth_layout);
  mFilePaths=getIntent().getExtras().getStringArray("paths");
  mDeviceData=new ArrayList<String>();
  mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
  if (mBluetoothAdapter == null) {
    AlertDialog.Builder b=new AlertDialog.Builder(this);
    b.setTitle("Bluetooth error").setMessage("This device does not support bluetooth").setIcon(R.drawable.download_md).setPositiveButton("Ok",new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        finish();
      }
    }
).create().show();
  }
  mDelegate=new BluetoothDeviceAdapter(this,R.layout.grid_content_layout,mDeviceData);
  GridView gview=(GridView)findViewById(R.id.bt_gridview);
  gview.setAdapter(mDelegate);
  gview.setOnItemClickListener(this);
  mMessageView=(TextView)findViewById(R.id.bt_message);
  mButton=(Button)findViewById(R.id.bt_button);
  mButton.setOnClickListener(this);
  if (!mBluetoothAdapter.isEnabled()) {
    mMessageView.setText("Bluetooth is turned off");
    mButton.setText("Enable Bluetooth");
    mButton.setId(BUTTON_ENABLE);
  }
 else {
    mMessageView.setText("Bluetooth is turned on");
    mButton.setText("Scan for Devices");
    mButton.setId(BUTTON_FIND);
    findPairedDevices();
  }
}
 

Example 37

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.

Source file: HelpActivity.java

  15 
vote

@Override public boolean shouldOverrideUrlLoading(WebView view,String url){
  if (url.startsWith("file")) {
    return false;
  }
 else   if (url.startsWith("mailto:")) {
    try {
      MailTo mt=MailTo.parse(url);
      Intent i=new Intent(Intent.ACTION_SEND);
      i.setType("message/rfc822");
      i.putExtra(Intent.EXTRA_EMAIL,new String[]{mt.getTo()});
      i.putExtra(Intent.EXTRA_SUBJECT,mt.getSubject());
      context.startActivity(i);
      view.reload();
    }
 catch (    ActivityNotFoundException e) {
      Log.w(TAG,"Problem with Intent.ACTION_SEND",e);
      new AlertDialog.Builder(context).setTitle("Contact Info").setMessage("Please send your feedback to: [email protected]").setPositiveButton("Done",new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          Log.d("AlertDialog","Positive");
        }
      }
).show();
    }
    return true;
  }
 else {
    startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(url)));
    return true;
  }
}
 

Example 38

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.

Source file: Term.java

  15 
vote

private void confirmCloseWindow(){
  final AlertDialog.Builder b=new AlertDialog.Builder(this);
  b.setIcon(android.R.drawable.ic_dialog_alert);
  b.setMessage(R.string.confirm_window_close_message);
  final Runnable closeWindow=new Runnable(){
    public void run(){
      doCloseWindow();
    }
  }
;
  b.setPositiveButton(android.R.string.yes,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      dialog.dismiss();
      mHandler.post(closeWindow);
    }
  }
);
  b.setNegativeButton(android.R.string.no,null);
  b.show();
}
 

Example 39

From project android-tether, under directory /src/og/android/tether/.

Source file: MainActivity.java

  15 
vote

@Override public boolean onTrackballEvent(MotionEvent event){
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
    Log.d(MSG_TAG,"Trackball pressed ...");
    String tetherStatus=this.application.coretask.getProp("tether.status");
    if (!tetherStatus.equals("running")) {
      new AlertDialog.Builder(this).setMessage(getString(R.string.main_activity_trackball_pressed_start)).setPositiveButton(getString(R.string.main_activity_confirm),new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          Log.d(MSG_TAG,"Trackball press confirmed ...");
          MainActivity.currentInstance.startBtnListener.onClick(MainActivity.currentInstance.startBtn);
        }
      }
).setNegativeButton(getString(R.string.main_activity_cancel),null).show();
    }
 else {
      if (MainActivity.this.lockBtn.isChecked()) {
        Log.d(MSG_TAG,"Tether was locked ...");
        MainActivity.this.application.displayToastMessage(getString(R.string.main_activity_locked));
        return false;
      }
      new AlertDialog.Builder(this).setMessage(getString(R.string.main_activity_trackball_pressed_stop)).setPositiveButton(getString(R.string.main_activity_confirm),new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          Log.d(MSG_TAG,"Trackball press confirmed ...");
          MainActivity.currentInstance.stopBtnListener.onClick(MainActivity.currentInstance.startBtn);
        }
      }
).setNegativeButton(getString(R.string.main_activity_cancel),null).show();
    }
  }
  return true;
}
 

Example 40

From project android-vpn-settings, under directory /src/com/android/settings/vpn/.

Source file: Util.java

  15 
vote

private static AlertDialog createErrorDialog(Context c,String message,DialogInterface.OnClickListener okListener){
  AlertDialog.Builder b=new AlertDialog.Builder(c).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(message);
  if (okListener != null) {
    b.setPositiveButton(R.string.vpn_back_button,okListener);
  }
 else {
    b.setPositiveButton(android.R.string.ok,null);
  }
  return b.create();
}
 

Example 41

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/activity/.

Source file: AddBookActivity.java

  15 
vote

@Override protected Dialog onCreateDialog(int id){
switch (id) {
case DIALOG_ADD:
    final AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(mBookToAdd != null ? mBookToAdd.getTitle() : " ");
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setMessage(R.string.dialog_add_message);
builder.setPositiveButton(R.string.dialog_add_ok,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
String bookId=mBookToAdd.getEan();
if (bookId == null) bookId=mBookToAdd.getIsbn();
if (bookId == null) bookId=mBookToAdd.getInternalIdNoPrefix();
onAdd(bookId);
mBookToAdd=null;
}
}
);
builder.setNegativeButton(R.string.dialog_add_cancel,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
mBookToAdd=null;
dismissDialog(DIALOG_ADD);
}
}
);
builder.setOnCancelListener(new DialogInterface.OnCancelListener(){
public void onCancel(DialogInterface dialog){
mBookToAdd=null;
dismissDialog(DIALOG_ADD);
}
}
);
builder.setCancelable(true);
return builder.create();
}
return super.onCreateDialog(id);
}
 

Example 42

From project AndroidExamples, under directory /RSSExample/src/com/robertszkutak/androidexamples/rss/.

Source file: RSSExampleActivity.java

  15 
vote

@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.newssettings:
    final CharSequence[] items={"Latest Articles","Academic News","Arts and Entertainment"};
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("Select a feed");
builder.setSingleChoiceItems(items,-1,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int item){
  Toast.makeText(getApplicationContext(),items[item],Toast.LENGTH_SHORT).show();
  final Editor editor=pref.edit();
switch (item) {
case 0:
    editor.putString("EXFEED","http://ww2.fredonia.edu/News/DesktopModules/DnnForge%20-%20NewsArticles/Rss.aspx?TabID=1101&ModuleID=1878&MaxCount=25");
  break;
case 1:
editor.putString("EXFEED","http://ww2.fredonia.edu/News/DesktopModules/DnnForge%20-%20NewsArticles/RSS.aspx?TabID=1101&ModuleID=1878&CategoryID=14");
break;
case 2:
editor.putString("EXFEED","http://ww2.fredonia.edu/News/DesktopModules/DnnForge%20-%20NewsArticles/RSS.aspx?TabID=1101&ModuleID=1878&CategoryID=28");
break;
}
editor.commit();
alert.cancel();
refreshCurrentFeed();
}
}
);
alert=builder.create();
alert.show();
break;
case R.id.newsrefresh:
refreshCurrentFeed();
break;
}
return true;
}
 

Example 43

From project Android_1, under directory /FixedSizeTextColumns/src/com/novoda/.

Source file: HelloWebView.java

  15 
vote

private Dialog getChooseViewDialog(){
  final String[] fileNames={"Two columns","Three columns","Two columns and photo"};
  final String[] filePaths={"file:///android_asset/two_columns.html","file:///android_asset/three_columns.html","file:///android_asset/two_columns_and_photo.html"};
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle("Choose a View");
  builder.setItems(fileNames,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int item){
      webView.loadUrl(filePaths[item]);
    }
  }
);
  return builder.create();
}
 

Example 44

From project android_5, under directory /src/aarddict/android/.

Source file: ArticleViewActivity.java

  15 
vote

private void showError(final String message){
  runOnUiThread(new Runnable(){
    public void run(){
      currentTask=null;
      setProgress(10000);
      resetTitleToCurrent();
      AlertDialog.Builder dialogBuilder=new AlertDialog.Builder(ArticleViewActivity.this);
      dialogBuilder.setTitle(R.string.titleError).setMessage(message).setNeutralButton(R.string.btnDismiss,new OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          dialog.dismiss();
          if (backItems.isEmpty()) {
            finish();
          }
        }
      }
);
      dialogBuilder.show();
    }
  }
);
}
 

Example 45

From project android_8, under directory /src/com/defuzeme/gui/.

Source file: Gui.java

  15 
vote

public void showAlertDialog(int title,int content){
  Gui._builder=new AlertDialog.Builder(this._activity);
  Gui._builder.setTitle(title);
  Gui._builder.setMessage(content);
  Gui._builder.setPositiveButton(android.R.string.ok,null);
  Gui._builder.setCancelable(false);
  Gui._builder.create().show();
}