Example usage for android.content Context getString

List of usage examples for android.content Context getString

Introduction

In this page you can find the example usage for android.content Context getString.

Prototype

@NonNull
public final String getString(@StringRes int resId) 

Source Link

Document

Returns a localized string from the application's package's default string table.

Usage

From source file:Main.java

public static String getAppName(Context cx) {
    return cx.getString(cx.getApplicationInfo().labelRes);
}

From source file:Main.java

public static String getApplicationName(Context context) {
    return context.getString(context.getApplicationInfo().labelRes);
}

From source file:Main.java

public static String toUpperCase(Context context, int i) {
    return context.getString(i).toUpperCase(Locale.getDefault());
}

From source file:Main.java

private static String getString(Context context, int resId) {
    return context.getString(resId);
}

From source file:Main.java

public static void showToast(int stringID, Context context) {
    Toast.makeText(context, context.getString(stringID), Toast.LENGTH_SHORT).show();
}

From source file:Main.java

/**
 * Converte uma chave em um texto presente no STRING.XML.
 * // www  .  j a v  a 2s. c  o  m
 * @param context
 *            Contexto onde se encontram o mapeamento de strings
 * @param chave
 *            Chave do texto a ser convertido
 * @return
 */
public static String getString(Context context, String chave) {
    return context.getString(context.getResources().getIdentifier(chave, "string", context.getPackageName()));
}

From source file:Main.java

public static void showMsgBox(Context context, int resId) {
    Toast.makeText(context, context.getString(resId), Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void showToast(Context ctx, int resId) {
    String message = ctx.getString(resId);
    showToast(ctx, message);/* w  w  w.  j  a v a 2 s . c  o m*/
}

From source file:Main.java

public static String getAppName(Context context) {
    try {/*w  w  w .  j a va2  s.  c  om*/
        return context.getString(context.getApplicationInfo().labelRes);
    } catch (Resources.NotFoundException e) {
        return "";
    }
}

From source file:Main.java

public static String getString(Context context, int resourceId) {
    return context != null ? context.getString(resourceId) : null;
}