List of usage examples for android.app AlertDialog show
public void show()
From source file:com.wikonos.fingerprint.activities.MainActivity.java
/** * Create dialog list of logs/*from w ww. j a v a 2 s .c o m*/ * * @return */ public AlertDialog getDialogReviewLogs() { /** * List of logs */ File folder = new File(LogWriter.APPEND_PATH); final String[] files = folder.list(new FilenameFilter() { public boolean accept(File dir, String filename) { if (filename.contains(".log") && !filename.equals(LogWriter.DEFAULT_NAME) && !filename.equals(LogWriterSensors.DEFAULT_NAME) && !filename.equals(ErrorLog.DEFAULT_NAME)) return true; else return false; } }); Arrays.sort(files); ArrayUtils.reverse(files); String[] files_with_status = new String[files.length]; String[] sent_mode = { "", "(s) ", "(e) ", "(s+e) " }; for (int i = 0; i < files.length; ++i) { //0 -- not sent //1 -- server //2 -- email files_with_status[i] = sent_mode[getSentFlags(files[i], this)] + files[i]; } if (files != null && files.length > 0) { final boolean[] selected = new boolean[files.length]; final AlertDialog ald = new AlertDialog.Builder(MainActivity.this) .setMultiChoiceItems(files_with_status, selected, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int which, boolean isChecked) { selected[which] = isChecked; } }) .setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { // removeDialog(DIALOG_ID_REVIEW); } }) /** * Delete log */ .setNegativeButton("Delete", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //Show delete confirm standardConfirmDialog("Delete Logs", "Are you sure you want to delete selected logs?", new OnClickListener() { //Confrim Delete @Override public void onClick(DialogInterface dialog, int which) { int deleteCount = 0; boolean flagSelected = false; for (int i = 0; i < selected.length; i++) { if (selected[i]) { flagSelected = true; LogWriter.delete(files[i]); LogWriter.delete(files[i].replace(".log", ".dev")); deleteCount++; } } reviewLogsCheckItems(flagSelected); removeDialog(DIALOG_ID_REVIEW); Toast.makeText(getApplicationContext(), deleteCount + " logs deleted.", Toast.LENGTH_SHORT).show(); } }, new OnClickListener() { //Cancel Delete @Override public void onClick(DialogInterface dialog, int which) { //Do nothing dialog.dismiss(); Toast.makeText(getApplicationContext(), "Delete cancelled.", Toast.LENGTH_SHORT).show(); } }, false); } }) /** * Send to server functional **/ .setNeutralButton("Send to Server", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (isOnline()) { ArrayList<String> filesList = new ArrayList<String>(); for (int i = 0; i < selected.length; i++) if (selected[i]) { filesList.add(LogWriter.APPEND_PATH + files[i]); //Move to httplogsender //setSentFlags(files[i], 1, MainActivity.this); //Mark file as sent } if (reviewLogsCheckItems(filesList.size() > 0 ? true : false)) { DataPersistence d = new DataPersistence(getApplicationContext()); new HttpLogSender(MainActivity.this, d.getServerName() + getString(R.string.submit_log_url), filesList) .setToken(getToken()).execute(); } // removeDialog(DIALOG_ID_REVIEW); } else { standardAlertDialog(getString(R.string.msg_alert), getString(R.string.msg_no_internet), null); } } }) /** * Email **/ .setPositiveButton("eMail", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { boolean flagSelected = false; // convert from paths to Android friendly // Parcelable Uri's ArrayList<Uri> uris = new ArrayList<Uri>(); for (int i = 0; i < selected.length; i++) if (selected[i]) { flagSelected = true; /** wifi **/ File fileIn = new File(LogWriter.APPEND_PATH + files[i]); Uri u = Uri.fromFile(fileIn); uris.add(u); /** sensors **/ File fileInSensors = new File( LogWriter.APPEND_PATH + files[i].replace(".log", ".dev")); Uri uSens = Uri.fromFile(fileInSensors); uris.add(uSens); setSentFlags(files[i], 2, MainActivity.this); //Mark file as emailed } if (reviewLogsCheckItems(flagSelected)) { /** * Run sending email activity */ Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Wifi Searcher Scan Log"); emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); startActivity(Intent.createChooser(emailIntent, "Send mail...")); } // removeDialog(DIALOG_ID_REVIEW); } }).create(); ald.getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { AlertDialog segmentNameAlert = segmentNameDailog("Rename Segment", ald.getContext(), files[position], null, view, files, position); segmentNameAlert.setCanceledOnTouchOutside(false); segmentNameAlert.show(); return false; } }); return ald; } else { return standardAlertDialog(getString(R.string.msg_alert), getString(R.string.msg_log_nocount), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_ID_REVIEW); } }); } }
From source file:com.example.yudiandrean.socioblood.ChangePassword.java
/** * Called when the activity is first created. *//*from w ww.ja v a 2 s.c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.changepassword); cancel = (Button) findViewById(R.id.btcancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { Intent login = new Intent(getApplicationContext(), LoginActivity.class); startActivity(login); finish(); } }); newpass = (EditText) findViewById(R.id.newpass); verifynewpass = (EditText) findViewById(R.id.verifynewpass); alert = (TextView) findViewById(R.id.alertpass); changepass = (Button) findViewById(R.id.btchangepass); changepass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (newpass.getText().toString().equals("")) { AlertDialog alertDialog = new AlertDialog.Builder(ChangePassword.this).create(); alertDialog.setTitle("Error"); alertDialog.setMessage("Password field is empty"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //dismiss the dialog } }); alertDialog.show(); } else if (!verifynewpass.getText().toString().equals(newpass.getText().toString())) { AlertDialog alertDialog = new AlertDialog.Builder(ChangePassword.this).create(); alertDialog.setTitle("Error"); alertDialog.setMessage("Passwords do not match, try again!"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //dismiss the dialog } }); alertDialog.show(); } else { NetAsync(view); } } }); }
From source file:com.deemsys.lmsmooc.BillingFragment.java
@SuppressWarnings("deprecation") @Override//from w w w. jav a 2s. co m public void onResume() { super.onResume(); if (isInternetPresent) { // onResume(); new Details().execute(); } else { AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create(); alertDialog.setTitle("Sorry User"); alertDialog.setMessage("No network connection."); alertDialog.setIcon(R.drawable.delete); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { } }); alertDialog.show(); } }
From source file:com.thadeus.youtube.IntroVideoActivity.java
private void showErrorAlert() { Builder lBuilder = new AlertDialog.Builder(IntroVideoActivity.this); lBuilder.setTitle(mMsgErrorTitle);//from w w w .ja v a 2s . co m lBuilder.setCancelable(false); lBuilder.setMessage(mMsgError); lBuilder.setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface pDialog, int pWhich) { IntroVideoActivity.this.finish(); } }); AlertDialog lDialog = lBuilder.create(); lDialog.show(); }
From source file:org.loon.framework.android.game.LGameActivity.java
/** * ??Android//from www . jav a2 s . co m * * @param exception */ private void androidException(Exception exception) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); try { throw exception; } catch (IOException e) { if (e.getMessage().startsWith("Network unreachable")) { builder.setTitle("No network"); builder.setMessage( "LGame-Android Remote needs local network access. Please make sure that your wireless network is activated. You can click on the Settings button below to directly access your network settings."); builder.setNeutralButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS)); } }); } else { builder.setTitle("Unknown I/O Exception"); builder.setMessage(e.getMessage().toString()); } } catch (HttpException e) { if (e.getMessage().startsWith("401")) { builder.setTitle("HTTP 401: Unauthorized"); builder.setMessage( "The supplied username and/or password is incorrect. Please check your settings."); builder.setNeutralButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent()); } }); } } catch (RuntimeException e) { builder.setTitle("RuntimeException"); builder.setMessage(e.getMessage()); } catch (Exception e) { builder.setTitle("Exception"); builder.setMessage(e.getMessage()); } finally { exception.printStackTrace(); builder.setCancelable(true); builder.setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); final AlertDialog alert = builder.create(); try { alert.show(); } catch (Throwable e) { } finally { LSystem.destroy(); } } }
From source file:de.baumann.hhsmoodle.activities.Activity_count.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceManager.setDefaultValues(this, R.xml.user_settings, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); toDo_title = sharedPref.getString("count_title", ""); String count_title = sharedPref.getString("count_content", ""); toDo_icon = sharedPref.getString("count_icon", ""); toDo_create = sharedPref.getString("count_create", ""); String todo_attachment = sharedPref.getString("count_attachment", ""); if (!sharedPref.getString("count_seqno", "").isEmpty()) { toDo_seqno = Integer.parseInt(sharedPref.getString("count_seqno", "")); }/*from w ww . ja v a 2s. c o m*/ setContentView(R.layout.activity_count); setTitle(toDo_title); final EditText etNewItem = (EditText) findViewById(R.id.etNewItem); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String itemText = etNewItem.getText().toString(); if (itemText.isEmpty()) { Snackbar.make(lvItems, R.string.todo_enter, Snackbar.LENGTH_LONG).show(); } else { itemsTitle.add(0, itemText); itemsCount.add(0, "0"); etNewItem.setText(""); writeItemsTitle(); writeItemsCount(); lvItems.post(new Runnable() { public void run() { lvItems.setSelection(lvItems.getCount() - 1); } }); adapter.notifyDataSetChanged(); } } }); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); helper_main.onStart(Activity_count.this); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } try { FileOutputStream fOut = new FileOutputStream(newFileTitle()); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); myOutWriter.append(count_title); myOutWriter.close(); fOut.flush(); fOut.close(); } catch (IOException e) { Log.e("Exception", "File write failed: " + e.toString()); } try { FileOutputStream fOut = new FileOutputStream(newFileCount()); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); myOutWriter.append(todo_attachment); myOutWriter.close(); fOut.flush(); fOut.close(); } catch (IOException e) { Log.e("Exception", "File write failed: " + e.toString()); } lvItems = (ListView) findViewById(R.id.lvItems); itemsTitle = new ArrayList<>(); readItemsTitle(); readItemsCount(); adapter = new CustomListAdapter(Activity_count.this, itemsTitle, itemsCount) { @NonNull @Override public View getView(final int position, View convertView, @NonNull ViewGroup parent) { View v = super.getView(position, convertView, parent); ImageButton ib_plus = (ImageButton) v.findViewById(R.id.but_plus); ImageButton ib_minus = (ImageButton) v.findViewById(R.id.but_minus); TextView tv = (TextView) v.findViewById(R.id.count_count); int count = Integer.parseInt(itemsCount.get(position)); if (count < 0) { tv.setTextColor(ContextCompat.getColor(Activity_count.this, R.color.color_red)); } else if (count > 0) { tv.setTextColor(ContextCompat.getColor(Activity_count.this, R.color.color_green)); } else if (count == 0) { tv.setTextColor(ContextCompat.getColor(Activity_count.this, R.color.color_grey)); } ib_plus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { int a = Integer.parseInt(itemsCount.get(position)) + 1; String plus = String.valueOf(a); itemsCount.remove(position); itemsCount.add(position, plus); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); } }); ib_minus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { int a = Integer.parseInt(itemsCount.get(position)) - 1; String minus = String.valueOf(a); itemsCount.remove(position); itemsCount.add(position, minus); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); } }); return v; } }; lvItems.setAdapter(adapter); lvItems.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(android.widget.AdapterView<?> parent, View view, final int position, long id) { final String title = itemsTitle.get(position); final String count = itemsCount.get(position); AlertDialog.Builder builder = new AlertDialog.Builder(Activity_count.this); View dialogView = View.inflate(Activity_count.this, R.layout.dialog_edit_text_singleline_count, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setText(title); builder.setView(dialogView); builder.setTitle(R.string.number_edit_entry); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTag = edit_title.getText().toString().trim(); // Remove the item within array at position itemsTitle.remove(position); itemsCount.remove(position); itemsTitle.add(position, inputTag); itemsCount.add(position, count); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(Activity_count.this, edit_title); } }); lvItems.setOnItemLongClickListener(new android.widget.AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(android.widget.AdapterView<?> parent, View view, final int position, long id) { final String title = itemsTitle.get(position); final String count = itemsCount.get(position); // Remove the item within array at position itemsTitle.remove(position); itemsCount.remove(position); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); Snackbar snackbar = Snackbar.make(lvItems, R.string.todo_removed, Snackbar.LENGTH_LONG) .setAction(R.string.todo_removed_back, new View.OnClickListener() { @Override public void onClick(View view) { itemsTitle.add(position, title); itemsCount.add(position, count); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); } }); snackbar.show(); return true; } }); }
From source file:markson.visuals.sitapp.CCActivity.java
@SuppressWarnings("deprecation") public void download() { AlertDialog alertDialog = new AlertDialog.Builder(CCActivity.this).create(); alertDialog.setTitle(cclass);/*from w ww .j a v a 2 s .c o m*/ alertDialog.setMessage("Class: " + num + "\n" + "Professor: " + instructor + "\n" + "Time: " + time + "\n" + "Date: " + date + "\n" + "CRN: " + crn + "\n"); alertDialog.setButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
From source file:com.wirelessmoves.cl.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case RESET_COUNTER: NumberOfCellChanges = 0;//from w w w . j a v a 2s .c o m NumberOfLacChanges = 0; NumberOfSignalStrengthUpdates = 0; NumberOfUniqueCellChanges = 0; /* Initialize PreviousCells Array to a defined value */ for (int x = 0; x < PreviousCells.length; x++) PreviousCells[x] = 0; return true; case ABOUT: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage( "Cell Logger\r\n2012, Martin Sauter\r\n2014, rong zedong.\r\nhttp://www.wirelessmoves.com") .setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return true; case TOGGLE_DEBUG: /* Toggle the debug behavior of the program when the user selects this menu item */ if (outputDebugInfo == false) { outputDebugInfo = true; } else { outputDebugInfo = false; } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.example.parking.ParkingInformationActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDBAdapter = new DBAdapter(this); setContentView(R.layout.activity_parking_information); mParkNameTV = (TextView) findViewById(R.id.tv_parking_name); mParkNameTV.setText(R.string.park_name_fixed); mParkNumberTV = (TextView) findViewById(R.id.tv_parking_number); mParkNumberTV.setText("?:" + this.getString(R.string.park_number_fixed)); mCarType = (Spinner) findViewById(R.id.sp_car_type); mParkingType = (Spinner) findViewById(R.id.sp_parking_type); mLocationNumber = (Spinner) findViewById(R.id.sp_parking_location); mLicensePlateNumberTV = (TextView) findViewById(R.id.tv_license_plate_number); Intent intent = getIntent();// w w w. ja va2 s .c om Bundle bundle = intent.getExtras(); mLicensePlateNumberTV.setText(bundle.getString("licensePlate")); mStartTime = (TextView) findViewById(R.id.tv_start_time_arriving); new TimeThread().start(); mOkButton = (Button) findViewById(R.id.bt_confirm_arriving); mOkButton.setOnClickListener(new InsertOnclickListener(mLicensePlateNumberTV.getText().toString(), mCarType.getSelectedItem().toString(), mParkingType.getSelectedItem().toString(), Integer.parseInt(mLocationNumber.getSelectedItem().toString()), DateFormat.format("yyyy-MM-dd HH:mm:ss", System.currentTimeMillis()).toString(), null, null, "")); mPhotoBT = (Button) findViewById(R.id.bt_camera_arriving); mPhotoBT.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { if (mEnterImage != null) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT) .show(); } else { openTakePhoto(); } } }); mPhotoTitleTV = (TextView) findViewById(R.id.tv_photo_title_arriving); mEnterImageIV = (ImageView) findViewById(R.id.iv_photo_arriving); mEnterImageIV.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); View imgEntryView = inflater.inflate(R.layout.dialog_photo_entry, null); // final AlertDialog dialog = new AlertDialog.Builder(ParkingInformationActivity.this).create(); ImageView img = (ImageView) imgEntryView.findViewById(R.id.iv_large_image); Button deleteBT = (Button) imgEntryView.findViewById(R.id.bt_delete_image); img.setImageBitmap(mEnterImage); dialog.setView(imgEntryView); // dialog dialog.show(); imgEntryView.setOnClickListener(new OnClickListener() { public void onClick(View paramView) { dialog.cancel(); } }); deleteBT.setOnClickListener(new OnClickListener() { public void onClick(View paramView) { mEnterImage = null; mEnterImageIV.setImageResource(drawable.ic_photo_background_64px); dialog.cancel(); } }); } }); getActionBar().setDisplayHomeAsUpEnabled(true); IntentFilter filter = new IntentFilter(); filter.addAction("ExitApp"); registerReceiver(mReceiver, filter); }
From source file:abanoubm.dayra.main.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { if (Utility.getArabicLang(getApplicationContext()) == 1) { Utility.setArabicLang(getApplicationContext(), 2); Locale myLocale = new Locale("ar"); Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale;/*from w w w . j a v a 2 s.co m*/ res.updateConfiguration(conf, dm); finish(); startActivity(new Intent(getIntent())); } super.onCreate(savedInstanceState); setContentView(R.layout.act_main); ((TextView) findViewById(R.id.subhead1)).setText(R.string.app_name); ((TextView) findViewById(R.id.subhead2)).setText(BuildConfig.VERSION_NAME); findViewById(R.id.nav_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); ((TextView) findViewById(R.id.footer)).setText("dayra " + BuildConfig.VERSION_NAME + " @" + new SimpleDateFormat("yyyy", Locale.getDefault()).format(new Date()) + " Abanoub M."); if (!Utility.getDayraName(getApplicationContext()).equals("")) { startActivity(new Intent(getApplicationContext(), Home.class)); finish(); } ListView lv = (ListView) findViewById(R.id.home_list); mMenuItemAdapter = new MenuItemAdapter(getApplicationContext(), new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.sign_menu))), 1); lv.setAdapter(mMenuItemAdapter); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: sign(); break; case 1: register(); break; case 2: if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { importDB(); } else { ActivityCompat.requestPermissions(Main.this, new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }, IMPORT_REQUEST); } break; case 3: startActivity(new Intent(Intent.ACTION_VIEW).setData( Uri.parse("https://drive.google.com/file/d/0B1rNCm5K9cvwVXJTTzNqSFdrVk0/view"))); break; case 4: startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse( "https://drive.google.com/open?id=1flSRdoiIT_hNd96Kxz3Ww3EhXDLZ45FhwFJ2hF9vl7g"))); break; case 5: { AlertDialog.Builder builder = new AlertDialog.Builder(Main.this); builder.setTitle(R.string.label_choose_language); builder.setItems(getResources().getStringArray(R.array.language_menu), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String temp; if (which == 1) { temp = "en"; Utility.setArabicLang(getApplicationContext(), 0); } else { temp = "ar"; Utility.setArabicLang(getApplicationContext(), 2); } Locale myLocale = new Locale(temp); Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale; res.updateConfiguration(conf, dm); finish(); startActivity(new Intent(getIntent())); } }); builder.create().show(); } break; case 6: try { getPackageManager().getPackageInfo("com.facebook.katana", 0); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/453595434816965")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/dayraapp")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } break; case 7: try { getPackageManager().getPackageInfo("com.facebook.katana", 0); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/1363784786")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/EngineeroBono")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } break; case 8: Uri uri = Uri.parse("market://details?id=" + getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); try { startActivity(goToMarket); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName()))); } break; case 9: if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(Intent.ACTION_VIEW).addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.setDataAndType(Uri.fromFile(new File(Utility.getDayraFolder())), "*/*"); startActivity( intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } else { ActivityCompat.requestPermissions(Main.this, new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, FOLDER_REQUEST); } break; case 10: LayoutInflater li = LayoutInflater.from(getApplicationContext()); final View aboutView = li.inflate(R.layout.dialogue_about, null, false); final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create(); ad.setView(aboutView, 0, 0, 0, 0); ad.show(); ((TextView) aboutView.findViewById(R.id.about)) .setText(String.format(getResources().getString(R.string.copyright), Calendar.getInstance().get(Calendar.YEAR))); ((TextView) aboutView.findViewById(R.id.notice)).setText(GoogleApiAvailability.getInstance() .getOpenSourceSoftwareLicenseInfo(getApplicationContext())); aboutView.findViewById(R.id.btn).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ad.cancel(); } }); break; } } }); }