Java Code Examples for android.content.DialogInterface

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 2Degrees-Toolbox, under directory /Toolbox/src/biz/shadowservices/DegreesToolbox/.

Source file: MainActivity.java

  30 
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 2

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

Source file: FragmentAlertDialogSupport.java

  29 
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 3

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

Source file: DialogPromptUIBehaviour.java

  29 
vote

public Dialog onCreateDialog(int id){
  AlertDialog.Builder builder=new AlertDialog.Builder(activity);
switch (id) {
case YES_NO_DIALOG:
    builder.setMessage("...").setPositiveButton("Yes",sendDialogResponseOf(true)).setNegativeButton("No",sendDialogResponseOf(false));
  break;
case STRING_ENTRY_DIALOG:
View textEntry=LayoutInflater.from(wrapWithDialogContext(activity)).inflate(R.layout.text_entry,null);
input=(EditText)textEntry.findViewById(R.id.text_entry_field);
builder.setTitle("...");
builder.setView(textEntry);
builder.setPositiveButton("OK",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
responseInterface.setResponse(input.getText().toString());
}
}
);
break;
}
return builder.create();
}
 

Example 4

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

Source file: StreamAdapter.java

  29 
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 5

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

Source file: ChartsDownloadActivity.java

  29 
vote

private void confirmStartDownload(final View v){
  int total=(Integer)v.getTag(R.id.DTPP_CHART_TOTAL);
  int avail=(Integer)v.getTag(R.id.DTPP_CHART_AVAIL);
  String tppVolume=(String)v.getTag(R.id.DTPP_VOLUME_NAME);
  AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
  builder.setTitle("Start Download");
  builder.setMessage(String.format("Do you want to download %d charts for %s volume?",total - avail,tppVolume));
  builder.setPositiveButton("Yes",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      startChartDownload(v);
    }
  }
);
  builder.setNegativeButton("No",null);
  builder.setIcon(android.R.drawable.ic_dialog_alert);
  builder.show();
}
 

Example 6

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

Source file: ActivityUtil.java

  29 
vote

public static void showAlertDialog(final Activity activity,final String titel,final String text){
  activity.runOnUiThread(new Runnable(){
    public void run(){
      aDialogBuilder=new AlertDialog.Builder(activity);
      aDialogBuilder.setMessage(text);
      aDialogBuilder.setTitle(titel);
      aDialogBuilder.setCancelable(false);
      aDialogBuilder.setPositiveButton("OK",new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          dialog.cancel();
        }
      }
);
      aDialog=aDialogBuilder.create();
      aDialog.show();
    }
  }
);
}
 

Example 7

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

Source file: ExistingIncidentsActivity.java

  29 
vote

@Override protected Dialog onCreateDialog(int id){
switch (id) {
case DIALOG_PROGRESS:
    mPd=new ProgressDialog(this);
  mPd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mPd.setIndeterminate(true);
mPd.setOnDismissListener(new OnDismissListener(){
@Override public void onDismiss(DialogInterface dialog){
  removeDialog(DIALOG_PROGRESS);
}
}
);
mPd.setOnCancelListener(new OnCancelListener(){
@Override public void onCancel(DialogInterface dialog){
AVService.getInstance(ExistingIncidentsActivity.this).cancelTask();
finish();
}
}
);
mPd.setMessage(getString(R.string.ui_message_loading));
return mPd;
default :
return super.onCreateDialog(id);
}
}
 

Example 8

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

Source file: Client.java

  29 
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 9

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

Source file: AmenoidApp.java

  29 
vote

public void uncaughtException(Thread thread,final Throwable ex){
  Log.e(TAG,"Uncaught exception",ex);
  ex.printStackTrace();
  if (ex.getCause() != null) {
    Log.e(TAG,"CAUSE",ex.getCause());
    ex.getCause().printStackTrace();
  }
  handler.post(new Runnable(){
    public void run(){
      Log.e(TAG,"Creating dialog");
      builder.setTitle(R.string.exception).setMessage(ex.getMessage()).setPositiveButton(R.string.ok,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialogInterface,        int i){
          Log.d(TAG,"OK clicked");
        }
      }
).show();
      Log.e(TAG,"Created dialog");
    }
  }
);
}
 

Example 10

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

Source file: Dialogs.java

  29 
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 11

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

Source file: AdmobAuthenticatorActivity.java

  29 
vote

@Override protected Dialog onCreateDialog(int id){
  ProgressDialog dialog=new ProgressDialog(this);
  dialog.setMessage("Authenticating...");
  dialog.setIndeterminate(true);
  dialog.setCancelable(true);
  dialog.setOnCancelListener(new DialogInterface.OnCancelListener(){
    @Override public void onCancel(    DialogInterface dialog){
      if (mAuthThread != null) {
        mAuthThread.interrupt();
        finish();
      }
    }
  }
);
  return dialog;
}
 

Example 12

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

Source file: AccountUtils.java

  29 
vote

/** 
 * Show conflict message about previously registered authenticator from another application
 * @param activity
 */
private static void showConflictMessage(final Activity activity){
  AlertDialog dialog=LightAlertDialog.create(activity);
  dialog.setTitle(activity.getString(string.authenticator_conflict_title));
  dialog.setMessage(activity.getString(string.authenticator_conflict_message));
  dialog.setOnCancelListener(new OnCancelListener(){
    @Override public void onCancel(    DialogInterface dialog){
      activity.finish();
    }
  }
);
  dialog.setButton(BUTTON_POSITIVE,activity.getString(android.R.string.ok),new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      activity.finish();
    }
  }
);
  dialog.show();
}
 

Example 13

From project android-aac-enc, under directory /src/com/todoroo/aacenc/.

Source file: Main.java

  29 
vote

private void write(){
  sr.setRecognitionListener(this);
  Intent intent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
  intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"com.domain.app");
  speechStarted=0;
  baos.reset();
  pd=new ProgressDialog(this);
  pd.setMessage("Speak now...");
  pd.setIndeterminate(true);
  pd.setCancelable(true);
  pd.setOnCancelListener(new OnCancelListener(){
    @Override public void onCancel(    DialogInterface dialog){
      sr.cancel();
      onEndOfSpeech();
    }
  }
);
  pd.show();
  sr.startListening(intent);
  speechStarted=System.currentTimeMillis();
}
 

Example 14

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

Source file: PhotoSyncActivity.java

  29 
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 15

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

Source file: MainActivity.java

  29 
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 16

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

Source file: BankEditActivity.java

  29 
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 17

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

Source file: QuickTest.java

  29 
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 18

From project android-client_1, under directory /src/com/googlecode/asmack/view/.

Source file: AuthenticatorActivity.java

  29 
vote

/** 
 * Create a wait dialog while the login thread is running.
 */
@Override protected Dialog onCreateDialog(int id){
  final ProgressDialog dialog=new ProgressDialog(this);
  dialog.setMessage("Login...");
  dialog.setIndeterminate(true);
  dialog.setCancelable(true);
  dialog.setOnCancelListener(new DialogInterface.OnCancelListener(){
    public void onCancel(    DialogInterface dialog){
      Log.i(TAG,"dialog cancel has been invoked");
      try {
        loginTestThread.interrupt();
        try {
          loginTestThread.join();
        }
 catch (        InterruptedException e) {
        }
      }
  finally {
        finish();
      }
    }
  }
);
  return dialog;
}
 

Example 19

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

Source file: UIUtils.java

  29 
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 20

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

Source file: ContextBrowserActivity.java

  29 
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 21

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

Source file: DonationsActivity.java

  29 
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 22

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

Source file: AtmaSelector.java

  29 
vote

@Override protected Dialog onCreateDialog(int id){
  FilterSelectorDialog dialog=new FilterSelectorDialog(this);
  dialog.setOnDismissListener(new OnDismissListener(){
    public void onDismiss(    DialogInterface dialog){
      FilterSelectorDialog fsd=(FilterSelectorDialog)dialog;
      String filter=fsd.getFilterString();
      mFilterID=fsd.getFilterID();
      if (filter.length() > 0) {
        AtmaListView alv=(AtmaListView)findViewById(R.id.ListView);
        if (alv != null) {
          alv.setFilter(filter);
        }
      }
    }
  }
);
  return dialog;
}
 

Example 23

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

Source file: EventHandler.java

  29 
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 24

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

Source file: BluetoothActivity.java

  29 
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 25

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

Source file: CardSetsFragment.java

  29 
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 26

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

Source file: AndroidFlashcards.java

  29 
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 27

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

Source file: BrowseGifsActivity.java

  29 
vote

@Override public void onClick(DialogInterface dialog,int which){
  if (dialog == this.mGifFileOptionsDialog) {
    this.mSS.inImageOptionsDialog=false;
switch (which) {
case 0:
      if (this.mSS.mPosition >= 0)       startShareLinkTask();
    break;
case 1:
  if (this.mSS.mPosition >= 0)   shareCurrentImage();
break;
case 2:
if (this.mSS.mPosition >= 0) {
this.showConfirmDeleteDialog();
return;
}
break;
}
}
 else if (dialog == this.mShareOptionsDialog) {
this.mSS.inShareOptionsDialog=false;
switch (which) {
case 0:
if (this.mSS.mPosition >= 0) startShareLinkTask();
break;
case 1:
if (this.mSS.mPosition >= 0) shareCurrentImage();
break;
}
}
 else if (dialog == this.mConfirmDeleteDialog) {
this.mSS.inConfirmDeleteDialog=false;
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
this.handleDeleteGif(this.mSS.mPosition);
break;
}
}
}
 

Example 28

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

Source file: TestConnect.java

  29 
vote

private void onTwitterClick(){
  if (mTwitter.hasAccessToken()) {
    final AlertDialog.Builder builder=new AlertDialog.Builder(this);
    builder.setMessage("Delete current Twitter connection?").setCancelable(false).setPositiveButton("Yes",new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int id){
        mTwitter.resetAccessToken();
        mTwitterBtn.setChecked(false);
        mTwitterBtn.setText("  Twitter (Not connected)");
        mTwitterBtn.setTextColor(Color.GRAY);
      }
    }
).setNegativeButton("No",new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int id){
        dialog.cancel();
        mTwitterBtn.setChecked(true);
      }
    }
);
    final AlertDialog alert=builder.create();
    alert.show();
  }
 else {
    mTwitterBtn.setChecked(false);
    mTwitter.authorize();
  }
}
 

Example 29

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

Source file: HelpActivity.java

  29 
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: app.ocr@gmail.com").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 30

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

Source file: AccessControlActivity.java

  29 
vote

@Override protected Dialog onCreateDialog(int id){
switch (id) {
case REMOVE_RULE:
    return new AlertDialog.Builder(AccessControlActivity.this).setIcon(R.drawable.alert_dialog_icon).setTitle("Remove Rule").setMessage("Would you like to remove this rule?").setPositiveButton("Remove",new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int whichButton){
        new DeleteNetworkItemTask().execute((Void[])null);
      }
    }
).setNegativeButton("Cancel",new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int whichButton){
      }
    }
).create();
}
return null;
}
 

Example 31

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/core/view/.

Source file: AlertUtils.java

  29 
vote

public static void showDeleteGroupWarning(final Context context,final String groupName,final String childName,final int childCount,final OnClickListener buttonListener){
  CharSequence title=context.getString(R.string.warning_title);
  CharSequence message=context.getString(R.string.delete_warning,groupName.toLowerCase(),childCount,childName.toLowerCase());
  CharSequence deleteButtonText=context.getString(R.string.menu_delete);
  CharSequence cancelButtonText=context.getString(R.string.cancel_button_title);
  OnCancelListener cancelListener=new OnCancelListener(){
    public void onCancel(    DialogInterface dialog){
      Log.d(cTag,"Cancelled delete. Do nothing.");
    }
  }
;
  Builder builder=new Builder(context);
  builder.setTitle(title).setIcon(R.drawable.dialog_warning).setMessage(message).setNegativeButton(cancelButtonText,buttonListener).setPositiveButton(deleteButtonText,buttonListener).setOnCancelListener(cancelListener);
  builder.create().show();
}
 

Example 32

From project Android-SyncAdapter-JSON-Server-Example, under directory /src/com/example/android/samplesync/authenticator/.

Source file: AuthenticatorActivity.java

  29 
vote

@Override protected Dialog onCreateDialog(int id){
  final ProgressDialog dialog=new ProgressDialog(this);
  dialog.setMessage(getText(R.string.ui_activity_authenticating));
  dialog.setIndeterminate(true);
  dialog.setCancelable(true);
  dialog.setOnCancelListener(new DialogInterface.OnCancelListener(){
    public void onCancel(    DialogInterface dialog){
      Log.i(TAG,"dialog cancel has been invoked");
      if (mAuthThread != null) {
        mAuthThread.interrupt();
        finish();
      }
    }
  }
);
  return dialog;
}
 

Example 33

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

Source file: Term.java

  29 
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 34

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

Source file: MainActivity.java

  29 
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 35

From project android-thaiime, under directory /common/src/com/android/ex/editstyledtext/.

Source file: EditStyledText.java

  29 
vote

private void buildDialogue(CharSequence title,CharSequence[] names,DialogInterface.OnClickListener l){
  mBuilder.setTitle(title);
  mBuilder.setIcon(0);
  mBuilder.setPositiveButton(null,null);
  mBuilder.setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      mEST.onStartEdit();
    }
  }
);
  mBuilder.setItems(names,l);
  mBuilder.setView(null);
  mBuilder.setCancelable(true);
  mBuilder.setOnCancelListener(new OnCancelListener(){
    public void onCancel(    DialogInterface arg0){
      if (DBG) {
        Log.d(TAG,"--- oncancel");
      }
      mEST.onStartEdit();
    }
  }
);
  mBuilder.show();
}
 

Example 36

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

Source file: AbstractContactPickerActivity.java

  29 
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 37

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

Source file: Util.java

  29 
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 38

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

Source file: HomeActivity.java

  29 
vote

@Override public Dialog onCreateDialog(int id){
  mProgressDialog=new ProgressDialog(this);
  mProgressDialog.setMessage("");
  mProgressDialog.setProgress(0);
  mProgressDialog.setOnCancelListener(new OnCancelListener(){
    public void onCancel(    DialogInterface dialog){
      mProgressThread.cancel();
    }
  }
);
  mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  mProgressDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
  return mProgressDialog;
}
 

Example 39

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/account/authenticator/.

Source file: AuthenticatorActivity.java

  29 
vote

@Override protected Dialog onCreateDialog(int id){
  final ProgressDialog dialog=new ProgressDialog(this);
  dialog.setMessage(getText(R.string.addaccount_progress_checkingapiversion));
  dialog.setIndeterminate(true);
  dialog.setCancelable(true);
  dialog.setOnCancelListener(new DialogInterface.OnCancelListener(){
    public void onCancel(    DialogInterface dialog){
      Log.i(TAG,"dialog cancel has been invoked");
      if (mAuthThread != null) {
        mAuthThread.interrupt();
        finish();
      }
    }
  }
);
  return dialog;
}
 

Example 40

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

Source file: AddBookActivity.java

  29 
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 41

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

Source file: RSSExampleActivity.java

  29 
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 42

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

Source file: GoogleHandle.java

  29 
vote

@Override public void onClick(DialogInterface dialog,int which){
  Account acc=accs[which];
  AQUtility.debug("acc",acc.name);
  setActiveAccount(act,acc.name);
  auth(acc);
}
 

Example 43

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

Source file: TiledMapActivity.java

  29 
vote

@Override public void onClick(DialogInterface dialog,int which){
  if (dialog == renameDialog) {
    final EditText input=(EditText)renameDialog.findViewById(R.id.tiledMap_dlg_rename_name);
    String mapName=input.getText().toString().trim();
    if (mapName.length() == 0) {
      mapName=getString(R.string.tiledMap_dlg_renameMap_noName);
    }
    if (which == DialogInterface.BUTTON_POSITIVE) {
      view.renameMap(mapName);
      getSupportActionBar().setTitle(mapName);
    }
 else     if (which == DialogInterface.BUTTON_NEGATIVE && (view.getMapName() == null || view.getMapName().trim().length() == 0)) {
      mapName=getString(R.string.tiledMap_dlg_renameMap_noName);
      view.renameMap(mapName);
      getSupportActionBar().setTitle(mapName);
    }
  }
 else   if (dialog == confirmMapSaveDialog) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
{
        Intent data=new Intent();
        data.putExtra(C.EXTRA_MAP_ID,mapId);
        data.putExtra(C.EXTRA_MAP_JSON,view.toJSON());
        data.putExtra(C.EXTRA_MAP_THUMB,view.exportThumb(CompressFormat.PNG,9));
        TiledMapActivity.this.setResult(RESULT_OK,data);
        TiledMapActivity.this.finish();
        break;
      }
case DialogInterface.BUTTON_NEGATIVE:
{
      TiledMapActivity.this.setResult(RESULT_CANCELED);
      TiledMapActivity.this.finish();
      break;
    }
}
}
}
 

Example 44

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

Source file: MainInput.java

  29 
vote

private void buildAlertMessageNoGps(){
  final AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setMessage("Your phone's GPS is disabled. CycleTracks needs GPS to determine your location.\n\nGo to System Settings now to enable GPS?").setCancelable(false).setPositiveButton("GPS Settings...",new DialogInterface.OnClickListener(){
    public void onClick(    final DialogInterface dialog,    final int id){
      final ComponentName toLaunch=new ComponentName("com.android.settings","com.android.settings.SecuritySettings");
      final Intent intent=new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
      intent.addCategory(Intent.CATEGORY_LAUNCHER);
      intent.setComponent(toLaunch);
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      startActivityForResult(intent,0);
    }
  }
).setNegativeButton("Cancel",new DialogInterface.OnClickListener(){
    public void onClick(    final DialogInterface dialog,    final int id){
      dialog.cancel();
    }
  }
);
  final AlertDialog alert=builder.create();
  alert.show();
}
 

Example 45

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

Source file: HelloWebView.java

  29 
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 46

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

Source file: ArticleViewActivity.java

  29 
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 47

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

Source file: UserDataManager.java

  29 
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 48

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

Source file: Gui.java

  29 
vote

public void showInputManualConnectDialog(int title,int content){
  this._inputText=new EditText(this._activity);
  this._inputText.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
  Gui._builder=new AlertDialog.Builder(this._activity);
  Gui._builder.setView(this._inputText);
  Gui._builder.setTitle(title);
  Gui._builder.setMessage(content);
  Gui._builder.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      if (isValidIPAddress(_inputText.getText().toString()) == true) {
        DefuzeMe.Network.connectIP(_inputText.getText().toString());
      }
 else {
        DefuzeMe.Gui.toast("\"" + _inputText.getText().toString() + "\" "+ DefuzeMe._mainActivity.getString(string.NotValidIPAddress));
      }
    }
  }
);
  Gui._builder.setNegativeButton(android.R.string.cancel,null);
  Gui._builder.setCancelable(true);
  Gui._builder.create().show();
}
 

Example 49

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

Source file: AccessibilitySettings.java

  29 
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();
  }
}