Example usage for android.content.res Resources getString

List of usage examples for android.content.res Resources getString

Introduction

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

Prototype

@NonNull
public String getString(@StringRes int id) throws NotFoundException 

Source Link

Document

Return the string value associated with a particular resource ID.

Usage

From source file:Main.java

public static CharSequence getString(Resources resources, int resource) {
    return resources.getString(resource);
}

From source file:Main.java

private static String createFromResource(final Activity activity, final int id) {
    final Resources resources = activity.getResources();
    return resources.getString(id);
}

From source file:Main.java

public static void showTips(Context ctx, int msgStringId) {

    Resources rc = ctx.getResources();
    String msg = rc.getString(msgStringId);
    showTips(ctx, msg);/*ww  w. j  a v a  2s.co m*/
}

From source file:Main.java

public static String getText(Activity showWebActivity, int loadingTrans) {
    Resources resources = showWebActivity.getResources();
    return resources.getString(loadingTrans);
}

From source file:Main.java

public static String getString(Context context, int res) {
    Resources resource = context.getResources();
    return resource.getString(res).toString();
}

From source file:Main.java

static String getOptionalStringResource(Resources resources, int stringResourceId, String defaultString) {
    try {//www  .  j  av  a2 s  . co m
        return resources.getString(stringResourceId);
    } catch (Resources.NotFoundException e) {
        return defaultString;
    }
}

From source file:com.apptentive.android.sdk.model.AutomatedMessage.java

public static AutomatedMessage createWelcomeMessage(Context context) {
    Resources resources = context.getResources();
    String title = resources.getString(R.string.apptentive_give_feedback);
    String body = resources.getString(R.string.apptentive_message_auto_body_manual);
    return createAutoMessage(title, body);
}

From source file:com.apptentive.android.sdk.model.AutomatedMessage.java

public static AutomatedMessage createNoLoveMessage(Context context) {
    Resources resources = context.getResources();
    String title = resources.getString(R.string.apptentive_were_sorry);
    String body = resources.getString(R.string.apptentive_message_auto_body_no_love);
    return createAutoMessage(title, body);
}

From source file:Main.java

/**
 * Get the value of "io.branch.sdk.TestMode" entry in application manifest or from String res.
 *
 * @return value of "io.branch.sdk.TestMode" entry in application manifest or String res.
 * false if "io.branch.sdk.TestMode" is not added in the manifest or String res.
 *//*from  ww  w  . java 2  s . c o m*/
public static boolean isTestModeEnabled(Context context) {
    if (isCustomDebugEnabled_) {
        return isCustomDebugEnabled_;
    }
    boolean isTestMode_ = false;
    String testModeKey = "io.branch.sdk.TestMode";
    try {
        final ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA);
        if (ai.metaData != null && ai.metaData.containsKey(testModeKey)) {
            isTestMode_ = ai.metaData.getBoolean(testModeKey, false);
        } else {
            Resources resources = context.getResources();
            isTestMode_ = Boolean.parseBoolean(resources
                    .getString(resources.getIdentifier(testModeKey, "string", context.getPackageName())));
        }

    } catch (Exception ignore) {
    }

    return isTestMode_;
}

From source file:com.android.utils.SharedPreferencesUtils.java

/**
 * Stores 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 value The value to store./*  w ww.  j av a  2  s. c o  m*/
 */
public static void putBooleanPref(SharedPreferences prefs, Resources res, int keyResId, boolean value) {
    storeBooleanAsync(prefs, res.getString(keyResId), value);
}