List of usage examples for android.content Context getString
@NonNull public final String getString(@StringRes int resId)
From source file:Main.java
/** * Return the name of application/*from w ww .j a v a 2 s . c o m*/ * @param context * @return */ public static String getApplicationName(Context context) { ApplicationInfo applicationInfo = context.getApplicationInfo(); return context.getString(applicationInfo.labelRes); }
From source file:Main.java
public static String getApplicationName(final Context context) { final ApplicationInfo applicationInfo = context.getApplicationInfo(); return context.getString(applicationInfo.labelRes); }
From source file:Main.java
/** * Show toast message.// ww w . j a v a 2 s .co m * * @param context Context * @param resIdOfMessage Resource id Of the message */ public static void ShowMessage(Context context, int resIdOfMessage) { if (context != null) { ShowMessage(context, context.getString(resIdOfMessage)); } }
From source file:Main.java
public static Typeface createTypeface(Context context, int typeface) { return Typeface.createFromAsset(context.getAssets(), String.format("fonts/%s.ttf", context.getString(typeface))); }
From source file:Main.java
public static String getStringByName(Context context, String name) { int id = context.getResources().getIdentifier(name, STRING, context.getPackageName()); return context.getString(id); }
From source file:Main.java
public static void showSingleToast(Context ctx, @StringRes int msgID, int duration) { String msg = ctx.getString(msgID); int showDuration = duration <= Toast.LENGTH_SHORT ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT; if (null == toast) { toast = Toast.makeText(ctx.getApplicationContext(), msgID, showDuration); toast.show();/*from w ww.j a v a 2 s. c o m*/ oneTime = System.currentTimeMillis(); } else { twoTime = System.currentTimeMillis(); if (msg.equals(oldMsg)) { if (twoTime - oneTime > showDuration) { toast.show(); } } else { oldMsg = msg; toast.setText(msg); toast.show(); } } oneTime = twoTime; }
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_communicator.services.LogService.java
public static boolean sendLogToServer(Context context) { String version = context.getString(R.string.version); String buildNumber = context.getString(R.string.build_number); log.debug("VERSION: {}, BUILD NUMBER: {}", new Object[] { version, buildNumber }); log.debug("sendLogToServer..."); File root = Environment.getExternalStorageDirectory(); File dir = new File(root + "/" + LOG_DIR); if (!dir.exists()) { if (!dir.mkdir()) { log.error("Cannot create dir {}", dir); }//from ww w . j ava2s . co m } File file; try { file = new File(root + "/" + LOG_DIR, Long.toString(System.currentTimeMillis())); log.debug("LOG FILE NAME: {}", file.getAbsolutePath()); Runtime.getRuntime().exec("logcat -d -v time -f " + file.getAbsolutePath()); } catch (IOException e) { log.error("Cannot read logcat", e); return false; } String channelId = ChannelService.getChannelId(context); try { HttpResp<Void> resp = HttpManager.sendPostVoid(context, context.getString(R.string.url_log, channelId), file); int code = resp.getCode(); if (code == HttpStatus.SC_FORBIDDEN || code == HttpStatus.SC_BAD_REQUEST) { throw new KurentoCommandException("Command error (" + code + ")"); } return code == HttpStatus.SC_CREATED; } catch (Exception e) { log.error("Cannot send log", e); return false; } }
From source file:Main.java
public static void show(Context paramContext, int paramInt) { if (paramContext == null) { return;//from w w w. jav a 2 s .co m } show(paramContext, paramContext.getString(paramInt)); }
From source file:Main.java
public static NotificationCompat.Builder buildNotification(Context context, Class<?> cls, int icon, int title, int text) { return buildNotification(context, cls, icon, title, context.getString(text)); }
From source file:Main.java
/** * // w w w . j ava2s. c o m * @param context * @param resId * @param gravity * @param xOffset * @param yOffset */ public static void showLong(Context context, int resId, int gravity, int xOffset, int yOffset) { showLong(context, context.getString(resId), gravity, xOffset, yOffset); }