List of usage examples for android.app Activity getString
@NonNull public final String getString(@StringRes int resId)
From source file:org.csploit.android.core.System.java
public static boolean checkNetworking(final Activity current) { if (!Network.isWifiConnected(mContext)) { Intent intent = new Intent(); intent.putExtra(WifiScannerActivity.CONNECTED, false); current.setResult(Activity.RESULT_OK, intent); String title = current.getString(R.string.error); String message = current.getString(R.string.wifi_went_down); new FatalDialog(title, message, current).show(); return false; }/* w w w . ja v a 2s . c o m*/ return true; }
From source file:com.dalaran.annotation.validator.Validator.java
private boolean checkFiledToEquals(Activity a, EqualsWith length, EditText o) { o.setError(null);/*from ww w . j a v a 2 s . c om*/ String s = o.getText().toString(); boolean matches = ((EditText) a.findViewById(length.value())).getText().toString().equals(s); if (!matches) { o.setError(a.getString(length.message())); } return !matches; }
From source file:org.catrobat.catroid.utils.UtilMerge.java
private static void showBackgroundNotEmptyDialog(Project projectToMergeFrom, final Activity activity) { final Project copyProjectToMergeFrom = projectToMergeFrom; final Activity copyActivity = activity; DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override//from ww w .j a v a2s . com public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: try { Project mergedProject = appendProjects(project, copyProjectToMergeFrom, copyActivity); ProjectManager.getInstance().setProject(mergedProject); ProjectManager.getInstance().saveProject(activity.getApplicationContext()); } catch (IOException e) { ToastUtil.showError(copyActivity, R.string.error_merge); Log.e(TAG, "IOException " + e.getMessage()); } break; } } }; String question = activity.getString(R.string.error_bricks_in_background); AlertDialog.Builder builder = new CustomAlertDialogBuilder(activity); builder.setTitle(R.string.warning); builder.setMessage(question); builder.setPositiveButton(activity.getString(R.string.main_menu_continue), dialogClickListener); builder.setNegativeButton(activity.getString(R.string.abort), dialogClickListener); Dialog errorDialog = builder.create(); errorDialog.show(); }
From source file:com.bt.heliniumstudentapp.MainActivity.java
protected static void setStatusBar(Activity context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { context.getWindow().setStatusBarColor(Color.TRANSPARENT); if (context == mainContext) drawerDL.setStatusBarBackgroundColor(ContextCompat.getColor(context, darkPrimaryColor)); else/*ww w.j a va 2 s .c om*/ context.getWindow().setStatusBarColor(ContextCompat.getColor(context, darkPrimaryColor)); context.setTaskDescription(new ActivityManager.TaskDescription(context.getString(R.string.app_name), BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher), ContextCompat.getColor(context, primaryColor))); } }
From source file:roommateapp.info.net.FileDownloader.java
/** * Constructor//from w w w.j a v a 2 s. c o m * * @param ac * @param roommateDirectory * @param username * @param pw */ public FileDownloader(Activity ac, File roommateDirectory, String username, String pw) { this.ac = ac; this.roommateDirectory = roommateDirectory; this.username = username; // Localisation this.dls = ac.getString(R.string.msg_downloadSuccess); this.dlf = ac.getString(R.string.msg_downloadFailed); this.valiFail = ac.getString(R.string.msg_novalidfile); this.dls_holiday = ac.getString(R.string.msg_holidayfiledownloaded); this.dialog_pleaseWait = ac.getString(R.string.pleaseWait); this.dialog_downloading = ac.getString(R.string.downloading); }
From source file:com.jetheis.android.makeitrain.fragment.ReportDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Activity activity = getActivity(); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); AlertDialog.Builder reportBuilder;//from w w w . ja v a 2 s. c om LayoutInflater reportInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View reportLayout = reportInflater.inflate(R.layout.report_dialog_fragment, null); int spent = preferences.getInt(activity.getString(R.string.pref_total_spent), 0); NumberFormat nf = NumberFormat.getCurrencyInstance(); String spentDisplay = nf.format(spent); TextView reportText = (TextView) reportLayout.findViewById(R.id.report_dialog_fragment_text_view); reportText.setText(activity.getString(R.string.total_spent, spentDisplay)); reportBuilder = new AlertDialog.Builder(activity); reportBuilder.setView(reportLayout); reportBuilder.setTitle(R.string.your_spending_report); reportBuilder.setPositiveButton(R.string.im_so_cool, null); reportBuilder.setNegativeButton(R.string.reset, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { dialog.dismiss(); Editor editor = preferences.edit(); editor.putInt(activity.getString(R.string.pref_total_spent), 0); editor.commit(); } }); return reportBuilder.create(); }
From source file:com.android.gallery3d.ui.MenuExecutor.java
public void onMenuClicked(int action, ProgressListener listener, boolean waitOnStop, boolean showDialog) { int title;/*from w ww. j a va2s .c o m*/ switch (action) { case R.id.action_select_all: if (mSelectionManager.inSelectAllMode()) { mSelectionManager.deSelectAll(); } else { mSelectionManager.selectAll(); } return; case R.id.action_crop: { Intent intent = getIntentBySingleSelectedPath(CropActivity.CROP_ACTION); ((Activity) mActivity).startActivity(intent); return; } case R.id.action_edit: { Intent intent = getIntentBySingleSelectedPath(Intent.ACTION_EDIT) .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); ((Activity) mActivity).startActivity(Intent.createChooser(intent, null)); return; } case R.id.action_setas: { Intent intent = getIntentBySingleSelectedPath(Intent.ACTION_ATTACH_DATA) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.putExtra("mimeType", intent.getType()); Activity activity = mActivity; activity.startActivity(Intent.createChooser(intent, activity.getString(R.string.set_as))); return; } case R.id.action_delete: title = R.string.delete; break; case R.id.action_rotate_cw: title = R.string.rotate_right; break; case R.id.action_rotate_ccw: title = R.string.rotate_left; break; case R.id.action_show_on_map: title = R.string.show_on_map; break; default: return; } startAction(action, title, listener, waitOnStop, showDialog); }
From source file:com.nbplus.vbroadlauncher.hybrid.BroadcastWebViewClient.java
public BroadcastWebViewClient(Activity activity, WebView view) { super(activity, view, activity.getString(R.string.app_name), activity.getString(R.string.app_name)); mWebView.setWebViewClient(this); mWebView.addJavascriptInterface(this, JAVASCRIPT_IF_NAME); mHandler = new BroadcastWebViewClientHandler(this); }
From source file:com.javielinux.utils.Utils.java
public static void sendLastCrash(Activity cnt) { try {//from w ww . j a v a 2 s . co m Intent gmail = new Intent(Intent.ACTION_VIEW); gmail.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail"); gmail.putExtra(Intent.EXTRA_EMAIL, new String[] { cnt.getString(R.string.email_send_errors) }); gmail.setData(Uri.parse(cnt.getString(R.string.email_send_errors))); gmail.putExtra(Intent.EXTRA_SUBJECT, "TweetTopics crash"); gmail.setType("plain/text"); gmail.putExtra(Intent.EXTRA_TEXT, ErrorReporter.getErrors(cnt)); cnt.startActivity(gmail); } catch (ActivityNotFoundException e) { Intent msg = new Intent(Intent.ACTION_SEND); msg.putExtra(Intent.EXTRA_EMAIL, new String[] { cnt.getString(R.string.email_send_errors) }); msg.putExtra(Intent.EXTRA_SUBJECT, "TweetTopics crash"); msg.setType("plain/text"); msg.putExtra(Intent.EXTRA_TEXT, ErrorReporter.getErrors(cnt)); cnt.startActivity(msg); } }
From source file:com.sourceallies.android.zonebeacon.adapter.MainAdapter.java
/** * Constructor for the spinnerAdapter.//from w w w.j ava 2 s.c o m * * @param context context for the activity * @param gateway the current gateway for the adapter */ public MainAdapter(@NonNull Activity context, @NonNull Gateway gateway) { this.context = context; this.viewHolders = new ArrayList<>(); this.executor = Executor.createForGateway(gateway); this.gateway = gateway; zonesTitle = context.getString(R.string.zones); buttonsTitle = context.getString(R.string.buttons); }