List of usage examples for android.content Context getString
@NonNull public final String getString(@StringRes int resId)
From source file:io.lqd.sdk.model.LQDevice.java
private static String getAppName(Context context) { int stringId = context.getApplicationInfo().labelRes; return context.getString(stringId); }
From source file:com.hybris.mobile.lib.commerce.helper.UrlHelper.java
/** * Return the webservice Http Address for token calls * * @param context Application-specific resources * @return Formatted String Url for WebService *//* ww w .ja va 2 s. com*/ public static String getWebserviceTokenUrl(Context context, Configuration configuration) { if (configuration == null || StringUtils.isBlank(configuration.getBackendUrl())) { throw new IllegalArgumentException(); } return configuration.getBackendUrl() + context.getString(R.string.path_token); }
From source file:com.hanuor.sapphire.hub.Internals.java
private static String getAppName(Context context) { int stringId = context.getApplicationInfo().labelRes; if (context.getString(stringId) != null) { return context.getString(stringId); } else {/*from ww w . ja v a2 s. c o m*/ return "null_app_name"; } }
From source file:com.teinproductions.tein.papyrosprogress.UpdateCheckReceiver.java
private static void issueBlogNotification(Context context) { String title = context.getString(R.string.notification_title); String message = context.getString(R.string.blog_notification_content); PendingIntent pendingIntent;// w w w . j a v a2s . com try { pendingIntent = PendingIntent.getActivity(context, 0, new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.PAPYROS_BLOG_URL)), PendingIntent.FLAG_UPDATE_CURRENT); } catch (Exception e) { e.printStackTrace(); return; } NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(message).setContentIntent(pendingIntent) .setSmallIcon(R.mipmap.notification_small_icon) .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) .setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(BLOG_NOTIFICATION_ID, builder.build()); }
From source file:Main.java
public static String getResourceString(String name, Context context) { int nameResourceID = context.getResources().getIdentifier(name, "string", context.getApplicationInfo().packageName); if (nameResourceID == 0) { return ""; //throw new IllegalArgumentException("No resource string found with name " + name); } else {// www . ja va 2s . c o m return context.getString(nameResourceID); } }
From source file:com.keylesspalace.tusky.util.NotificationMaker.java
@Nullable private static String joinNames(Context context, JSONArray array) throws JSONException { if (array.length() > 3) { return String.format(context.getString(R.string.notification_summary_large), array.get(0), array.get(1), array.get(2), array.length() - 3); } else if (array.length() == 3) { return String.format(context.getString(R.string.notification_summary_medium), array.get(0), array.get(1), array.get(2)); } else if (array.length() == 2) { return String.format(context.getString(R.string.notification_summary_small), array.get(0), array.get(1));//from w w w . j a v a 2s .c om } return null; }
From source file:es.uniovi.imovil.fcrtrainer.highscores.HighscoreManager.java
/** * Aade una puntuacin a los datos de mejores puntuaciones * // w w w. j a v a2 s .c om * @param context * Contexto para gestionar recursos * @param score * Puntos obtenidos * @param exercise * Ejercicio donde se han obtenido. Debe ser una de las * constantes usadas en FragmentFactory para lanzar el fragmento, * por ejemplo, R.string.logic_gate * @param date * Fecha en la que se obtuvo la puntuacin * @param userName * Nombre del usuario que obtuvo la puntuacin. Si se pasa null, * ser el nombre de usuario por defecto * @throws JSONException * Cuando no se puede pasar a JSON o de JSON una puntuacin */ public static void addScore(Context context, int score, int exercise, Date date, String userName) throws JSONException { if (userName == null) { userName = context.getString(R.string.default_user_name); } Highscore highscore = new Highscore(score, exercise, date, userName); ArrayList<Highscore> highscores = new ArrayList<Highscore>(); try { highscores = loadHighscores(context); } catch (JSONException e) { Log.d(TAG, "Error al leer las puntuaciones para aadir una nueva: " + e.getMessage()); } highscores.add(highscore); highscores = trim(highscores, MAX_NUMBER_HIGHSCORES); saveHighscores(context, highscores); }
From source file:com.wms.opensource.shopfast.shopify.Cart.java
public static void loadFromJSONFile(Context context) { String cartFilePath = StorageUtil.getTempDirectoryPath(context) + "/" + context.getString(R.string.cartFileName); boolean cartFileExists = FileUtil.fileExist(cartFilePath); if (cartFileExists) { String jsonString = FileUtil.readStringFromFile(StorageUtil.getTempDirectory(context), context.getString(R.string.cartFileName), context.getString(R.string.charSetName)); JSONArray jsonArray;/* w w w . j a v a 2s . com*/ try { jsonArray = new JSONArray(jsonString); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObj = jsonArray.getJSONObject(i); Item item = new Item(); item.setOption(jsonObj.getString("option")); if (jsonObj.has("optionName")) { item.setOptionName(jsonObj.getString("optionName")); } item.setPrice(jsonObj.getDouble("price")); item.setProductID(jsonObj.getInt("productID")); item.setProductImageSrc(jsonObj.getString("productImageSrc")); item.setProductName(jsonObj.getString("productName")); item.setQuantity(jsonObj.getInt("quantity")); item.setVariantID(jsonObj.getInt("variantID")); items.add(item); } } catch (JSONException e) { } } }
From source file:gov.nasa.arc.geocam.talk.UIUtils.java
/** * Show the {@link GeoCamTalkMapActivity} for a given message. * * @param context The current activity context * @param talkMessage The {@link GeoCamTalkMessage} that the map activity will display *//*from www . j av a 2 s. c o m*/ public static void showMapView(Context context, GeoCamTalkMessage talkMessage) { final Intent intent = new Intent(context, GeoCamTalkMapActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(context.getString(R.string.latitude), talkMessage.getLatitude()); intent.putExtra(context.getString(R.string.longitude), talkMessage.getLongitude()); intent.putExtra(context.getString(R.string.accuracy), talkMessage.getAccuracy()); context.startActivity(intent); }
From source file:com.keylesspalace.tusky.util.NotificationMaker.java
@Nullable private static String titleForType(Context context, Notification notification) { switch (notification.type) { case MENTION: return String.format(context.getString(R.string.notification_mention_format), notification.account.getDisplayName()); case FOLLOW:/*from w ww.ja v a2 s .c om*/ return String.format(context.getString(R.string.notification_follow_format), notification.account.getDisplayName()); case FAVOURITE: return String.format(context.getString(R.string.notification_favourite_format), notification.account.getDisplayName()); case REBLOG: return String.format(context.getString(R.string.notification_reblog_format), notification.account.getDisplayName()); } return null; }