List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:com.mono.applink.Facebook.java
/** Called when the activity is first created. */ @Override//from w w w. ja v a 2 s .c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; final String url = getIntent().getData().toString(); if (url.contains("posts") || url.contains("profile.php") || (!url.contains("&") && !url.contains("=") && url.length() > 24)) //1)Posts->It is impossible to launch FeedbackActivity because of permission denied. //With root permission and "am start" it's impossible to pass a Long extra_key... //2)Profile //3)Nickname { new FacebookUser().execute(); } else if (url.contains("sk=inbox"))//Message { new FacebookMessage().execute(); } else if (url.contains("event.php"))//event { new FacebookEvent().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.andybotting.tubechaser.activity.StationDetail.java
/** * Show line select dialog/*from w ww .j ava 2 s .com*/ */ private void showLineSelect(final List<Line> lines) { ListAdapter adapter = new LinesListAdapter(mContext, -1, lines); final AlertDialog.Builder ad = new AlertDialog.Builder(this); ad.setTitle("Select Line"); ad.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mLine = lines.get(which); dialog.dismiss(); displayStation(); } }); ad.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { // Just end our activity if no line is selected StationDetail.this.finish(); } }); ad.create(); ad.show(); }
From source file:pl.bcichecki.rms.client.android.activities.NewMessageActivity.java
private void createRecipentsListDialog() { usernames = new String[users.size()]; chosenUsers = new boolean[users.size()]; for (int i = 0; i < users.size(); i++) { usernames[i] = users.get(i).getUsername(); }/*from w w w.ja va 2 s .co m*/ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); dialogBuilder.setTitle(R.string.activity_new_message_pick_recipents); dialogBuilder.setMultiChoiceItems(usernames, chosenUsers, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if (isChecked) { pickedUsers.add(users.get(which)); recipentsEditText.setError(null); } else { pickedUsers.remove(users.get(which)); } updateRecipentsEditText(); } }); dialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Nothing to do... } }); recipentsListDialog = dialogBuilder.create(); }
From source file:com.nuvolect.securesuite.data.SqlSyncTest.java
public void pingPongConfirmDiag(final Activity act) { m_act = act;//from w w w .j a v a2 s. c o m if (!WebUtil.companionServerAssigned()) { Toast.makeText(act, "Configure companion device for test to operate", Toast.LENGTH_LONG).show(); return; } String title = "Pyramid comm test with companion device"; String message = "This is a non-destructive network performance test. " + "Payload size is incrementally increased."; AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle(title); builder.setMessage(Html.fromHtml(message)); builder.setIcon(CConst.SMALL_ICON); builder.setCancelable(true); builder.setPositiveButton("Start test", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setProgressCallback(m_act, pingPongCallbacks); pingPongProgress(act); SqlSyncTest.getInstance().init();// Small amount of init on UI thread WorkerCommand.quePingTest(m_act);// Heavy lifting on non-UI thread } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog_alert.cancel(); } }); dialog_alert = builder.create(); dialog_alert.show(); // Activate the HTML TextView tv = ((TextView) dialog_alert.findViewById(android.R.id.message)); tv.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.cloudant.todo.TodoActivity.java
public Dialog createProgressDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); final View v = this.getLayoutInflater().inflate(R.layout.dialog_loading, null); DialogInterface.OnClickListener negativeClick = new DialogInterface.OnClickListener() { @Override// w w w. j a v a 2s . c o m public void onClick(DialogInterface dialog, int which) { stopReplication(); } }; DialogInterface.OnKeyListener keyListener = new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Toast.makeText(getApplicationContext(), R.string.replication_running, Toast.LENGTH_LONG).show(); return true; } return false; } }; builder.setView(v).setNegativeButton("Stop", negativeClick).setOnKeyListener(keyListener); return builder.create(); }
From source file:gr.scify.newsum.ui.SearchViewActivity.java
private void Copy() { // TextView tx = (TextView) findViewById(R.id.textView1); TextView title = (TextView) findViewById(R.id.title); String sdtitle = title.getText().toString(); // String copytext = tx.getText().toString(); String alphaAndDigits = sdtitle.replaceAll("[^\\p{L}\\p{N}]", " "); Boolean isSDPresent = android.os.Environment.getExternalStorageState() .equals(android.os.Environment.MEDIA_MOUNTED); // track the copy to SD button if (getAnalyticsPref()) { EasyTracker.getTracker().sendEvent(SHARING_ACTION, "Save to SD", alphaAndDigits, 0l); }/* w ww .jav a2s .com*/ if (isSDPresent) { File folder = new File(Environment.getExternalStorageDirectory() + "/NewSum"); boolean success = false; if (!folder.exists()) { success = folder.mkdir(); } if (!success) { // Do something on success } else { // Do something else on failure } File logFile = new File(folder, alphaAndDigits + ".txt"); // File logFile = new // File(Environment.getExternalStorageDirectory().toString(), // alphaAndDigits+".txt"); if (!logFile.exists()) { try { logFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } BufferedWriter output = null; try { output = new BufferedWriter(new FileWriter(logFile)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { output.write(pText); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { output.close(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.save_massage); builder.setMessage(logFile.getPath()); builder.setPositiveButton(getResources().getText(R.string.ok).toString(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog a = builder.create(); a.show(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Toast.makeText(SearchViewActivity.this, R.string.check_sd, Toast.LENGTH_SHORT).show(); } }
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java
@Override public void onUpdateCheckCompleted(UpdateManager manager, final Update update) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); if (update.forceExit) { builder.setTitle(R.string.service_is_not_available); } else if (update.forceUpdate) { builder.setTitle(R.string.update_required); } else {/*from w w w .j a va2 s . co m*/ builder.setTitle(R.string.update_found); } final View dialogContentsView = createUpdatesFoundDialogContentsView(update); builder.setView(dialogContentsView); initializeUpdatesFoundDialogButtons(builder, update); builder.setCancelable(false); final AlertDialog alertDialog = builder.create(); alertDialog.show(); }
From source file:com.timemachine.controller.ControllerActivity.java
private void buildDisconnectDialog() { AlertDialog.Builder disconnectDialogBuilder = new AlertDialog.Builder(ControllerActivity.this); disconnectDialogBuilder.setMessage("Are you sure you want to disconnect?"); disconnectDialogBuilder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { disconnectController();/*from ww w . j a v a 2s . c o m*/ } }); disconnectDialogBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); disconnectDialog = disconnectDialogBuilder.create(); }
From source file:com.abc.driver.TruckActivity.java
public void chooseTruckLength(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(this); GridView gridView1 = new GridView(this); gridView1.setNumColumns(3);/*from w w w.j a v a2 s. c om*/ // (GridView)findViewById(R.id.gridView1); SimpleAdapter adapter = new SimpleAdapter(this, mTruckLengthList, R.layout.truck_length_griditem, new String[] { "TITLE", "TLENGTH" }, new int[] { R.id.griditem_title, R.id.griditem_length, }); gridView1.setAdapter(adapter); builder.setTitle("Please Choose"); builder.setInverseBackgroundForced(true); builder.setView(gridView1); final Dialog dialog = builder.create(); gridView1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { mTLtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText()); mTruckLength = ((TextView) view.findViewById(R.id.griditem_length)).getText().toString(); mUpdateTruckTask = new UpdateTruckTask(); mUpdateTruckTask.execute("" + app.getUser().getMyTruck().getTruckId(), "" + app.getUser().getMyTruck().getTypeId(), mTruckLength, "" + app.getUser().getMyTruck().getWeightId(), "" + app.getUser().getMyTruck().getStatusId(), "" + app.getUser().getId()); dialog.dismiss(); } }); dialog.show(); }
From source file:com.richtodd.android.quiltdesign.app.MainActivity.java
@Override protected void onStart() { super.onStart(); try {// www.j a va 2 s . c o m if (Repository.getDefaultRepository(this).isEmpty() && !hasSampleLoaderTask()) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Would you like to add some sample blocks and quilts?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { SampleLoaderTask task = new SampleLoaderTask(); setSampleLoaderTask(task); task.execute(MainActivity.this); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // No action required. } }); Dialog dialog = builder.create(); dialog.show(); } } catch (RepositoryException e) { Handle.asRuntimeError(e); } }