List of usage examples for android.app AlertDialog.Builder setIcon
public void setIcon(Drawable icon)
From source file:pl.bcichecki.rms.client.android.activities.LoginActivity.java
protected void performLogin() { Log.d(TAG, "Performing login... [username=" + username + ", password=" + password + "]"); profileRestClient = new ProfileRestClient(CONTEXT, username, password, SharedPreferencesWrapper.getServerRealm(), SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(), SharedPreferencesWrapper.getWebserviceContextPath()); profileRestClient.getProfile(new GsonHttpResponseHandler<User>(new TypeToken<User>() { }.getType(), true) {//from w ww .ja v a 2 s. co m @Override public void onFailure(Throwable error, String content) { Log.d(TAG, "Getting profile failed! [error=" + error + ", content=" + content + "]"); AlertDialog.Builder errorDialog = new AlertDialog.Builder(CONTEXT); errorDialog.setIcon(android.R.drawable.ic_dialog_alert); if (error instanceof HttpResponseException) { if (((HttpResponseException) error).getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { errorDialog.setTitle(R.string.activity_login_unsuccessful_login_message_title); errorDialog.setMessage(R.string.activity_login_unsuccessful_login_message_content); } else { errorDialog.setTitle(R.string.general_unknown_error_message_title); errorDialog .setMessage(String.format(getString(R.string.general_unknown_error_message_content), (HttpResponseException) error)); } } else { errorDialog.setTitle(R.string.general_unknown_error_message_title); errorDialog.setMessage( String.format(getString(R.string.general_unknown_error_message_content), error)); } errorDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = errorDialog.show(); TextView messageText = (TextView) dialog.findViewById(android.R.id.message); messageText.setGravity(Gravity.CENTER); } @Override public void onFinish() { showProgress(false); Log.d(TAG, "Getting profile finished."); } @Override public void onStart() { Log.d(TAG, "Getting profile started."); showProgress(true); } @Override public void onSuccess(int statusCode, User user) { Log.d(TAG, "Success [statusCode=" + statusCode + ", jsonObject=" + user.toString() + "]"); UserProfileHolder.setUserProfile(user); UserProfileHolder.setUsername(username); UserProfileHolder.setPassword(password); AppUtils.showCenteredToast(CONTEXT, R.string.activity_login_login_successful, Toast.LENGTH_SHORT); Intent mainActivityIntent = new Intent(CONTEXT, MainActivity.class); startActivity(mainActivityIntent); } }); }
From source file:rs.pedjaapps.kerneltuner.ui.BuildpropEditor.java
@Override public void onCreate(Bundle savedInstanceState) { entries = new ArrayList<>(); preferences = PreferenceManager.getDefaultSharedPreferences(this); super.onCreate(savedInstanceState); setContentView(R.layout.build);/* w w w . j a va 2 s .c o m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); bListView = (ListView) findViewById(R.id.list); bAdapter = new BuildAdapter(this, new ArrayList<Build>()); bListView.setAdapter(bAdapter); bListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, final int pos, long is) { AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); final Build build = bAdapter.getItem(pos); builder.setTitle(build.key); builder.setIcon(R.drawable.build); final EditText input = new EditText(v.getContext()); input.setText(build.value); input.selectAll(); input.setGravity(Gravity.CENTER_HORIZONTAL); input.requestFocus(); builder.setPositiveButton(getString(R.string.Change), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { build.value = input.getText().toString().trim(); saveBuildProp(build); } }); builder.setNegativeButton(getResources().getString(R.string.cancel), null); builder.setView(input); AlertDialog alert = builder.create(); alert.show(); } }); new GetBuildEntries().execute(); }
From source file:br.com.GUI.perfil.HomeAluno.java
public boolean onOptionsItemSelected(MenuItem item) { // Take appropriate action for each action item click switch (item.getItemId()) { case R.id.actSolicitacoesDeAmizadeAluno: Personal solicitacoes = new Aluno() .buscarPersonalNaoConfirmadoPorAlunoWeb(pref.getString("usuario", null)); Log.i("usuario", solicitacoes.toString()); if (solicitacoes.getUsuario() != null) { Intent i = new Intent(this, SolicitacoesDeAmizade.class); startActivity(i);//from w w w . jav a 2 s. c om } else { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Ops..."); alertDialog.setMessage(R.string.label_voce_nao_possui_solicitacoes_de_amizade); alertDialog.setIcon(R.drawable.profile); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } return true; case R.id.actLogoutAluno: finish(); Intent login = new Intent(this, Login.class); login.putExtra("logout", true); editor.clear(); editor.commit(); startActivity(login); return true; case R.id.actAdicionarPersonal: Intent adicionarAlunos = new Intent(this, BuscarUsuario.class); startActivity(adicionarAlunos); return true; case R.id.actAlterarDadosPessoaisAluno: if (pref.getBoolean("isFacebookUser", false)) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(HomeAluno.this); alertDialog.setTitle("Erro"); alertDialog.setMessage( "Seu cadastro est vinculado ao Facebook, sendo assim, no possivel alterao de informaes pessoais"); alertDialog.setIcon(R.drawable.profile); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } else { Intent alterarDados = new Intent(this, AlterarDadosPessoais.class); startActivity(alterarDados); } return true; case R.id.actPerfil: Intent perfilIntent = new Intent(this, PerfilPersonal.class); startActivity(perfilIntent); return true; case R.id.actMarcarAula: Aluno a = new Aluno().buscarAlunoEspecifico(b, pref.getString("usuario", null)); if (a.getUsuarioPersonal() != null) { Intent marcarAulaIntent = new Intent(this, MarcarAula.class); startActivity(marcarAulaIntent); } else { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Ops..."); alertDialog.setMessage("Antes de voc agendar uma aula necessrio que voc " + " possua um treinador para lhe auxiliar na sua rotina de exerccios"); alertDialog.setIcon(R.drawable.horarios); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } return true; case R.id.actNovaAvaliacao: Intent avaliacoesIntent = new Intent(this, AvaliarGorduraCorporal.class); startActivity(avaliacoesIntent); return true; } return false; }
From source file:edu.cwru.apo.Home.java
public void onRestRequestComplete(Methods method, JSONObject result) { if (method == Methods.phone) { if (result != null) { try { String requestStatus = result.getString("requestStatus"); if (requestStatus.compareTo("success") == 0) { SharedPreferences.Editor editor = getSharedPreferences(APO.PREF_FILE_NAME, MODE_PRIVATE) .edit();//from w w w .ja v a2 s . c o m editor.putLong("updateTime", result.getLong("updateTime")); editor.commit(); int numbros = result.getInt("numBros"); JSONArray caseID = result.getJSONArray("caseID"); JSONArray first = result.getJSONArray("first"); JSONArray last = result.getJSONArray("last"); JSONArray phone = result.getJSONArray("phone"); JSONArray family = result.getJSONArray("family"); ContentValues values; for (int i = 0; i < numbros; i++) { values = new ContentValues(); values.put("_id", caseID.getString(i)); values.put("first", first.getString(i)); values.put("last", last.getString(i)); values.put("phone", phone.getString(i)); values.put("family", family.getString(i)); database.replace("phoneDB", null, values); } } else if (requestStatus.compareTo("timestamp invalid") == 0) { Toast msg = Toast.makeText(this, "Invalid timestamp. Please try again.", Toast.LENGTH_LONG); msg.show(); } else if (requestStatus.compareTo("HMAC invalid") == 0) { Auth.loggedIn = false; Toast msg = Toast.makeText(this, "You have been logged out by the server. Please log in again.", Toast.LENGTH_LONG); msg.show(); finish(); } else { Toast msg = Toast.makeText(this, "Invalid requestStatus", Toast.LENGTH_LONG); msg.show(); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } else if (method == Methods.checkAppVersion) { if (result != null) { try { String requestStatus = result.getString("requestStatus"); if (requestStatus.compareTo("success") == 0) { String appVersion = result.getString("version"); String appDate = result.getString("date"); final String appUrl = result.getString("url"); PackageInfo pinfo = this.getPackageManager().getPackageInfo(getPackageName(), 0); ; if (appVersion.compareTo(pinfo.versionName) != 0) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Upgrade"); builder.setMessage("Update available, ready to upgrade?"); builder.setIcon(R.drawable.icon); builder.setCancelable(false); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent promptInstall = new Intent("android.intent.action.VIEW", Uri.parse("https://apo.case.edu:8090/app/" + appUrl)); startActivity(promptInstall); } }); builder.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } else { Toast msg = Toast.makeText(this, "No updates found", Toast.LENGTH_LONG); msg.show(); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
From source file:tools.ToolsManpowerHomeActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment;//from w w w. j a v a 2 s . c o m Bundle bundle; FragmentManager fragmentManager; switch (position) { case 0: fragment = new ToolsManpowerHomeFragmet(); bundle = new Bundle(); // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(bundle); fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mFarmerTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); break; case 1: fragment = new UpdateManpowerFragmet(); bundle = new Bundle(); // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(bundle); fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mFarmerTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); break; case 2: fragment = new ToolUpdateFragmet(); bundle = new Bundle(); // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(bundle); fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mFarmerTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); break; case 3: AlertDialog.Builder bulder = new AlertDialog.Builder(ToolsManpowerHomeActivity.this); bulder.setTitle("Are you sure ?...."); bulder.setIcon(R.drawable.ic_launcher); bulder.setMessage("You want to Logout"); bulder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub Intent intent = new Intent(ToolsManpowerHomeActivity.this, MainActivity.class); startActivity(intent); } }); bulder.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub Toast.makeText(ToolsManpowerHomeActivity.this, "Welldone", Toast.LENGTH_LONG).show(); dialog.dismiss(); } }); AlertDialog d = bulder.create(); d.show(); break; case 4: break; default: break; } }
From source file:id.ridon.keude.Keude.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_APPDETAILS: break;//w w w . j av a2 s . c om case REQUEST_MANAGEREPOS: if (data != null && data.hasExtra(ManageReposActivity.REQUEST_UPDATE)) { AlertDialog.Builder ask_alrt = new AlertDialog.Builder(this); ask_alrt.setTitle(getString(R.string.repo_update_title)); ask_alrt.setIcon(android.R.drawable.ic_menu_rotate); ask_alrt.setMessage(getString(R.string.repo_alrt)); ask_alrt.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { updateRepos(); } }); ask_alrt.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // do nothing } }); AlertDialog alert = ask_alrt.create(); alert.show(); } break; case REQUEST_PREFS: // The automatic update settings may have changed, so reschedule (or // unschedule) the service accordingly. It's cheap, so no need to // check if the particular setting has actually been changed. UpdateService.schedule(getBaseContext()); if ((resultCode & PreferencesActivity.RESULT_RESTART) != 0) { ((KeudeApp) getApplication()).reloadTheme(); final Intent intent = getIntent(); overridePendingTransition(0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); finish(); overridePendingTransition(0, 0); startActivity(intent); } break; case REQUEST_ENABLE_BLUETOOTH: fdroidApp.sendViaBluetooth(this, resultCode, "id.ridon.keude"); break; } }
From source file:com.innoc.secureline.ui.UpgradeCallDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder; if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) { builder = new AlertDialog.Builder( new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog)); } else {/* ww w. ja v a2s. co m*/ builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog); } builder.setIcon(R.drawable.red_call); final String upgradeString = getActivity().getResources() .getString(R.string.RedPhoneChooser_upgrade_to_redphone); SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString); titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); builder.setTitle(titleBuilder); //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call); builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(getActivity(), SecureLineService.class); intent.setAction(SecureLineService.ACTION_OUTGOING_CALL); intent.putExtra(Constants.REMOTE_NUMBER, number); getActivity().startService(intent); Intent activityIntent = new Intent(); activityIntent.setClass(getActivity(), SecureLine.class); activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(activityIntent); getActivity().finish(); } }); builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { CallChooserCache.getInstance().addInsecureChoice(number); Intent intent = new Intent("android.intent.action.CALL", Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); getActivity().finish(); } }); AlertDialog alert = builder.create(); alert.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { getActivity().finish(); } }); ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { getActivity().finish(); } }); Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE); } }); return alert; }
From source file:com.mindprotectionkit.freephone.ui.UpgradeCallDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder; if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) { builder = new AlertDialog.Builder( new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog)); } else {/* w ww . j a v a 2 s .c o m*/ builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog); } builder.setIcon(R.drawable.red_call); final String upgradeString = getActivity().getResources() .getString(R.string.RedPhoneChooser_upgrade_to_redphone); SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString); titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); builder.setTitle(titleBuilder); //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call); builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(getActivity(), RedPhoneService.class); intent.setAction(RedPhoneService.ACTION_OUTGOING_CALL); intent.putExtra(Constants.REMOTE_NUMBER, number); getActivity().startService(intent); Intent activityIntent = new Intent(); activityIntent.setClass(getActivity(), RedPhone.class); activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(activityIntent); getActivity().finish(); } }); builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { CallChooserCache.getInstance().addInsecureChoice(number); Intent intent = new Intent("android.intent.action.CALL", Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); getActivity().finish(); } }); AlertDialog alert = builder.create(); alert.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { getActivity().finish(); } }); ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { getActivity().finish(); } }); Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE); } }); return alert; }
From source file:edu.cmu.cs.cloudlet.android.CloudletActivity.java
private void showDialogSelectOverlay(final ArrayList<VMInfo> vmList) { String[] nameList = new String[vmList.size()]; for (int i = 0; i < nameList.length; i++) { nameList[i] = new String(vmList.get(i).getAppName()); }/*from w w w . ja v a 2s . c om*/ AlertDialog.Builder ab = new AlertDialog.Builder(this); ab.setTitle("Overlay List"); ab.setIcon(R.drawable.ic_launcher); ab.setSingleChoiceItems(nameList, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { selectedOveralyIndex = position; } }).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { if (position >= 0) { selectedOveralyIndex = position; } VMInfo overlayVM = vmList.get(selectedOveralyIndex); runConnection(CLOUDLET_SYNTHESIS_IP, CLOUDLET_SYNTHESIS_PORT, overlayVM); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { return; } }); ab.show(); }
From source file:edu.cmu.cs.cloudlet.android.CloudletActivity.java
private void showDialogSelectApp(final String[] applications) { // Show Dialog AlertDialog.Builder ab = new AlertDialog.Builder(this); ab.setTitle("Application List"); ab.setIcon(R.drawable.ic_launcher); ab.setSingleChoiceItems(applications, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { selectedOveralyIndex = position; }//from www. ja v a2 s . c om }).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { if (position >= 0) { selectedOveralyIndex = position; } else if (applications.length > 0 && selectedOveralyIndex == -1) { selectedOveralyIndex = 0; } String application = applications[selectedOveralyIndex]; runStandAlone(application); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { return; } }); ab.show(); }