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:com.rincliu.library.common.reference.social.weibo.RLWeiboHelper.java

private RLWeiboHelper(Context context) {
    if (weibo == null) {
        String key = context.getString(R.string.weibo_key);
        weibo = Weibo.getInstance(key, REDIRECT_URL + key);
    }/*w w  w  .  j  a v  a  2  s .  c om*/
}

From source file:de.dekies.android.websms.connector.smsglobal.ConnectorSmsGlobal.java

/**
 * {@inheritDoc}/*from www.j  a va 2 s .  c  o  m*/
 */
@Override
public final ConnectorSpec initSpec(final Context context) {
    final String name = context.getString(R.string.connector_smsglobal_name);
    ConnectorSpec c = new ConnectorSpec(name);
    c.setAuthor(context.getString(R.string.connector_smsglobal_author));
    c.setBalance(null);
    c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND
            | ConnectorSpec.CAPABILITIES_PREFS);
    c.addSubConnector(TAG, name, (SubConnectorSpec.FEATURE_CUSTOMSENDER | SubConnectorSpec.FEATURE_SENDLATER));
    return c;
}

From source file:org.quantumbadger.redreader.reddit.api.RedditOAuth.java

private static FetchUserInfoResult fetchUserInfoSynchronous(final Context context,
        final AccessToken accessToken) {

    final URI uri = Constants.Reddit.getUri(Constants.Reddit.PATH_ME);
    StatusLine responseStatus = null;//from   www  .  j a  v a  2s  .  c  om

    try {
        final HttpClient httpClient = CacheManager.createHttpClient(context);

        final HttpGet request = new HttpGet(uri);
        request.addHeader("Authorization", "bearer " + accessToken.token);

        final HttpResponse response = httpClient.execute(request);
        responseStatus = response.getStatusLine();

        if (responseStatus.getStatusCode() != 200) {
            return new FetchUserInfoResult(FetchUserInfoResultStatus.CONNECTION_ERROR,
                    new RRError(context.getString(R.string.error_unknown_title),
                            context.getString(R.string.error_unknown_message), null, responseStatus,
                            uri.toString()));
        }

        final JsonValue jsonValue = new JsonValue(response.getEntity().getContent());
        jsonValue.buildInThisThread();
        final JsonBufferedObject responseObject = jsonValue.asObject();

        final String username = responseObject.getString("name");

        if (username == null || username.length() == 0) {
            return new FetchUserInfoResult(FetchUserInfoResultStatus.INVALID_RESPONSE,
                    new RRError(context.getString(R.string.error_unknown_title),
                            context.getString(R.string.error_unknown_message), null, responseStatus,
                            uri.toString()));
        }

        return new FetchUserInfoResult(username);

    } catch (IOException e) {
        return new FetchUserInfoResult(FetchUserInfoResultStatus.CONNECTION_ERROR,
                new RRError(context.getString(R.string.error_connection_title),
                        context.getString(R.string.error_connection_message), e, responseStatus,
                        uri.toString()));

    } catch (Throwable t) {
        return new FetchUserInfoResult(FetchUserInfoResultStatus.UNKNOWN_ERROR,
                new RRError(context.getString(R.string.error_unknown_title),
                        context.getString(R.string.error_unknown_message), t, responseStatus, uri.toString()));
    }
}

From source file:altermarkive.uploader.Config.java

private int storing() {
    Context context = sampler.context();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    String key = context.getString(R.string.storing);
    int storing = Integer.parseInt(preferences.getString(key, "0"));
    return storing;
}

From source file:de.ub0r.android.websms.connector.smstrade.ConnectorSMStrade.java

/**
 * {@inheritDoc}//from ww w. j a  v  a  2s  .  c o  m
 */
@Override
public final ConnectorSpec initSpec(final Context context) {
    final String name = context.getString(R.string.connector_smstrade_name);
    ConnectorSpec c = new ConnectorSpec(name);
    c.setAuthor(// .
            context.getString(R.string.connector_smstrade_author));
    c.setBalance(null);
    c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND
            | ConnectorSpec.CAPABILITIES_PREFS);
    c.addSubConnector(ID_BASIC, context.getString(R.string.basic), 0);
    c.addSubConnector(ID_ECONOMY, context.getString(R.string.economy), 0);
    c.addSubConnector(ID_GOLD, context.getString(R.string.gold), 0);
    c.addSubConnector(ID_DIRECT, context.getString(R.string.direct), 0);
    return c;
}

From source file:arc.noaa.weather.activities.MainActivity.java

public static String localize(SharedPreferences sp, Context context, String preferenceKey,
        String defaultValueKey) {
    String preferenceValue = sp.getString(preferenceKey, defaultValueKey);
    String result = preferenceValue;
    if ("speedUnit".equals(preferenceKey)) {
        if (speedUnits.containsKey(preferenceValue)) {
            result = context.getString(speedUnits.get(preferenceValue));
        }/*from w  ww  . j  a  va  2 s. co m*/
    } else if ("pressureUnit".equals(preferenceKey)) {
        if (pressUnits.containsKey(preferenceValue)) {
            result = context.getString(pressUnits.get(preferenceValue));
        }
    }
    return result;
}

From source file:com.juick.android.Utils.java

public static boolean hasAuth(Context context) {
    AccountManager am = AccountManager.get(context);
    Account accs[] = am.getAccountsByType(context.getString(R.string.com_juick));
    return accs.length > 0;
}

From source file:com.gmail.altakey.lucene.AsyncImageLoader.java

private String getUserAgent() {
    Context context = this.view.getContext();
    return String.format("%s/%s", context.getString(R.string.app_name),
            context.getString(R.string.app_version));
}

From source file:altermarkive.uploader.Config.java

private void naming(int type, int index, String name) {
    Context context = sampler.context();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    String key = String.format(context.getString(R.string.naming), type, index);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString(key, name);/*w ww.  jav  a  2  s .  c  o m*/
    editor.commit();
}

From source file:altermarkive.uploader.Config.java

private int sampling(int type, int index) {
    Context context = sampler.context();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    String key = String.format(context.getString(R.string.sampling), type, index);
    int sampling = Integer.parseInt(preferences.getString(key, "0"));
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString(key, Integer.toString(sampling));
    editor.commit();/*from w ww  .jav a2  s .  c o  m*/
    return sampling;
}