List of usage examples for android.content.res Resources getString
@NonNull public String getString(@StringRes int id) throws NotFoundException
From source file:com.android.utils.SharedPreferencesUtils.java
/** * Returns the value of a string preference. * * @param prefs Shared preferences from which to obtain the value. * @param res Resources from which to obtain the key and default value. * @param keyResId Resource identifier for the key. * @param defaultResId Resource identifier for the default value. * @return The preference value, or the default value if not set. *//*from ww w. j a va2 s. c om*/ public static String getStringPref(SharedPreferences prefs, Resources res, int keyResId, int defaultResId) { return prefs.getString(res.getString(keyResId), ((defaultResId == 0) ? null : res.getString(defaultResId))); }
From source file:com.android.utils.SharedPreferencesUtils.java
/** * Returns the value of a boolean preference. * * @param prefs Shared preferences from which to obtain the value. * @param res Resources from which to obtain the key and default value. * @param keyResId Resource identifier for the key. * @param defaultResId Resource identifier for the default value. * @return The preference value, or the default value if not set. *//* w ww . ja va2 s . c om*/ public static boolean getBooleanPref(SharedPreferences prefs, Resources res, int keyResId, int defaultResId) { return prefs.getBoolean(res.getString(keyResId), res.getBoolean(defaultResId)); }
From source file:com.achep.acdisplay.DialogHelper.java
public static void showCryDialog(@NonNull ActionBarActivity activity) { Check.getInstance().isInMainThread(); Resources res = activity.getResources(); CharSequence message = Html.fromHtml(res.getString(R.string.cry_dialog_message)); new DialogBuilder(activity).setIcon(R.drawable.ic_action_about_white).setTitle(R.string.cry_dialog_title) .setMessage(message).createAlertDialogBuilder().setNegativeButton(R.string.close, null).create() .show();/*from w ww . j a v a 2 s. co m*/ }
From source file:com.bullmobi.message.ui.DialogHelper.java
public static void showCryDialog(@NonNull ActionBarActivity activity) { Check.getInstance().isInMainThread(); Resources res = activity.getResources(); CharSequence message = Html.fromHtml(res.getString(R.string.cry_dialog_message)); new MaterialDialog.Builder(activity).iconRes(R.drawable.ic_action_about_white) .title(R.string.cry_dialog_title).content(message).negativeText(R.string.close).build().show(); }
From source file:com.android.utils.SharedPreferencesUtils.java
/** * Returns the value of an integer preference stored as a string. This is * necessary when using a {@link android.preference.ListPreference} to * manage an integer preference, since the entries must be {@link String} * values.//from w w w .jav a2 s . c o m * * @param prefs Shared preferences from which to obtain the value. * @param res Resources from which to obtain the key and default value. * @param keyResId Resource identifier for the key. * @param defaultResId Resource identifier for the default value. * @return The preference value, or the default value if not set. */ public static int getIntFromStringPref(SharedPreferences prefs, Resources res, int keyResId, int defaultResId) { final String strPref = prefs.getString(res.getString(keyResId), res.getString(defaultResId)); return Integer.parseInt(strPref); }
From source file:com.achep.acdisplay.ui.DialogHelper.java
public static void showCryDialog(@NonNull AppCompatActivity activity) { Check.getInstance().isInMainThread(); Resources res = activity.getResources(); CharSequence message = Html.fromHtml(res.getString(R.string.cry_dialog_message)); new MaterialDialog.Builder(activity).iconRes(R.drawable.ic_action_about_white) .title(R.string.cry_dialog_title).content(message).negativeText(R.string.close).build().show(); }
From source file:com.android.utils.SharedPreferencesUtils.java
/** * Returns the value of a floating point preference stored as a string. This * is necessary when using a {@link android.preference.ListPreference} to * manage a floating point preference, since the entries must be * {@link String} values./* w ww . ja va2s. c o m*/ * * @param prefs Shared preferences from which to obtain the value. * @param res Resources from which to obtain the key and default value. * @param keyResId Resource identifier for the key. * @param defaultResId Resource identifier for the default value. * @return The preference value, or the default value if not set. */ public static float getFloatFromStringPref(SharedPreferences prefs, Resources res, int keyResId, int defaultResId) { final String strPref = prefs.getString(res.getString(keyResId), res.getString(defaultResId)); return Float.parseFloat(strPref); }
From source file:com.sublimis.urgentcallfilter.MyPreference.java
private static String getStringResource(int resId) { Resources res = getResources(); if (res != null) return res.getString(resId); else//from w w w. ja v a 2 s.c o m return null; }
From source file:Main.java
public static String[] getItemStrings(Resources res, int iconsRes) { if (iconsRes == 0) return null; TypedArray array = res.obtainTypedArray(iconsRes); int n = array.length(); String ids[] = new String[n]; for (int i = 0; i < n; ++i) { ids[i] = res.getString(array.getResourceId(i, 0)); }// ww w.ja v a 2s. com array.recycle(); return ids; }
From source file:com.android.usbtuner.setup.TunerSetupActivity.java
/** * Sends the recommendation card to start the USB tuner TV input setup activity. * * @param context a {@link Context} instance */// w w w . j a va 2s . c o m private static void sendRecommendationCard(Context context) { Resources resources = context.getResources(); String focusedTitle = resources.getString(R.string.ut_setup_recommendation_card_focused_title); String title = resources.getString(R.string.ut_setup_recommendation_card_title); Bitmap largeIcon = BitmapFactory.decodeResource(resources, R.drawable.recommendation_antenna); // Build and send the notification. Notification notification = new NotificationCompat.BigPictureStyle(new NotificationCompat.Builder(context) .setAutoCancel(false).setContentTitle(focusedTitle).setContentText(title).setContentInfo(title) .setCategory(Notification.CATEGORY_RECOMMENDATION).setLargeIcon(largeIcon) .setSmallIcon(resources.getIdentifier(TAG_ICON, TAG_DRAWABLE, context.getPackageName())) .setContentIntent(createPendingIntentForSetupActivity(context))).build(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFY_TAG, NOTIFY_ID, notification); }