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

/**
 * Mostra un messaggio TOAST/*from w ww . j  av a2s .  c o  m*/
 */
public static void showToast(Context context, int resourceId) {
    showToast(context, context.getString(resourceId));
}

From source file:Main.java

public static void showToast(Context context, int contentid, boolean longTime) {
    showToast(context, context.getString(contentid), false);
}

From source file:Main.java

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

From source file:Main.java

public static String getAppName(Context context) {
    int stringId = context.getApplicationInfo().labelRes;
    return context.getString(stringId);
}

From source file:Main.java

private static boolean getPreferenceBoolean(SharedPreferences sharedPref, Context context, int StrRes,
        int strResDefValue) {
    return sharedPref.getBoolean(context.getString(StrRes), Boolean.valueOf(context.getString(strResDefValue)));
}

From source file:Main.java

public static void toast(Context context, int strResId, int duration) {
    toast(context, context.getString(strResId), duration);
}

From source file:Main.java

private static String getPreferenceString(SharedPreferences sharedPref, Context context, int StrRes,
        String defValue) {/*from  w w  w .jav a2  s. com*/
    return sharedPref.getString(context.getString(StrRes), defValue);
}

From source file:Main.java

/**
 * Show a dialog that has one button - OK
 * @param context Context to grab string resources
 * @param titleRes String resource id to be put in the title
 * @param msgRes String resource id to be put in the message
 *///from ww w.  j av  a  2 s  .  c o m
public static void showOkDialog(Context context, int titleRes, int msgRes) {
    new AlertDialog.Builder(context).setTitle(context.getString(titleRes)).setMessage(context.getString(msgRes))
            .setNegativeButton(android.R.string.ok, (dialogInterface, i) -> dialogInterface.cancel()).show();
}

From source file:Main.java

private static String getString(Context context, int id) {
    if (id == 0) {
        return null;
    }/*from  w  w w  . j  av a  2  s . co  m*/
    return context.getString(id);
}

From source file:com.bottlerocketstudios.groundcontrolsample.core.controller.ProductApi.java

public static Request createConfigurationRequest(Context context) {
    String configUrl = context.getString(R.string.config_url);
    return new Request.Builder().url(configUrl).get().build();
}