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:com.google.android.gms.common.internal.C1339l.java

private static String m4744a(Context context, String str, String str2) {
    Resources resources = context.getResources();
    String a = C1339l.m4743a(context, str);
    if (a == null) {
        a = resources.getString(C1095b.common_google_play_services_unknown_issue);
    }//from  www. j  a va2 s  .  c  o  m
    return String.format(resources.getConfiguration().locale, a, new Object[] { str2 });
}

From source file:com.google.android.gms.common.internal.C1339l.java

public static String m4748e(Context context, int i) {
    Resources resources = context.getResources();
    switch (i) {//from   w  w  w  . jav a 2 s .c  o  m
    case GoogleMap.MAP_TYPE_NORMAL /*1*/:
        return resources.getString(C1095b.common_google_play_services_install_button);
    case GoogleMap.MAP_TYPE_SATELLITE /*2*/:
        return resources.getString(C1095b.common_google_play_services_update_button);
    case GoogleMap.MAP_TYPE_TERRAIN /*3*/:
        return resources.getString(C1095b.common_google_play_services_enable_button);
    default:
        return resources.getString(17039370);
    }
}

From source file:com.android.messaging.util.AccessibilityUtil.java

public static void getVocalizedNumber(final Resources res, final char c, final StringBuilder builder) {
    switch (c) {/*from w  ww. java  2s  .  c  om*/
    case '0':
        builder.append(res.getString(R.string.content_description_for_number_zero));
        builder.append(" ");
        return;
    case '1':
        builder.append(res.getString(R.string.content_description_for_number_one));
        builder.append(" ");
        return;
    case '2':
        builder.append(res.getString(R.string.content_description_for_number_two));
        builder.append(" ");
        return;
    case '3':
        builder.append(res.getString(R.string.content_description_for_number_three));
        builder.append(" ");
        return;
    case '4':
        builder.append(res.getString(R.string.content_description_for_number_four));
        builder.append(" ");
        return;
    case '5':
        builder.append(res.getString(R.string.content_description_for_number_five));
        builder.append(" ");
        return;
    case '6':
        builder.append(res.getString(R.string.content_description_for_number_six));
        builder.append(" ");
        return;
    case '7':
        builder.append(res.getString(R.string.content_description_for_number_seven));
        builder.append(" ");
        return;
    case '8':
        builder.append(res.getString(R.string.content_description_for_number_eight));
        builder.append(" ");
        return;
    case '9':
        builder.append(res.getString(R.string.content_description_for_number_nine));
        builder.append(" ");
        return;
    default:
        builder.append(c);
        return;
    }
}

From source file:com.tedx.logics.AttendeeLogic.java

public static Bundle GetCurrentDancers(Resources res, String EventUniqueId) {
    String Action = "GetAttendeeByUniqueId";

    JSONObject requestJSONParameters = new JSONObject();
    try {/*from   www . ja va 2  s.  c om*/
        requestJSONParameters.put("EventId", Integer.valueOf(res.getString(R.string.eventId)));
        requestJSONParameters.put("EventUniqueId", EventUniqueId);
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        return null;
    }

    String URL = res.getString(R.string.WebServiceAddress) + Action;

    JSONObject responseJSON = WebServices.SendHttpPost(URL, requestJSONParameters);

    if (responseJSON != null) {
        try {
            if (responseJSON.getBoolean("IsSuccessful")) {
                Bundle ret = new Bundle();
                ret.putInt("AttendeeId", responseJSON.getInt("AttendeeId"));
                ret.putString("FirstName", responseJSON.getString("FirstName"));
                ret.putString("LastName", responseJSON.getString("LastName"));
                ret.putString("ContactNumber", responseJSON.getString("ContactNumber"));
                ret.putString("Website", responseJSON.getString("Website"));
                ret.putString("Email", responseJSON.getString("Email"));
                ret.putString("Facebook", responseJSON.getString("Facebook"));
                ret.putString("Twitter", responseJSON.getString("Twitter"));
                ret.putString("Description", responseJSON.getString("Description"));

                return ret;
            } else
                return null;
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            return null;
        }
    } else
        return null;
}

From source file:co.vanir.indecentxposure.IndecentXposure.java

public static void notify(final Context context, final String exampleString) {
    final Resources res = context.getResources();

    final String ticker = exampleString;
    final String title = res.getString(R.string.solve_problems_notification_title); //_template, exampleString);
    final String text = res.getString(R.string.solve_problems_notification_placeholder_text_template);//, exampleString);

    //one button opens the "uninstall app" settings page
    final Intent removeIntent = new Intent();
    removeIntent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", SerialOffender.getPackageName(), null);
    removeIntent.setData(uri);/*from w w  w  .j av  a2 s  . co m*/

    //the other option will hide the notification until the user uninstalls and reinstalls
    //  the installer
    final Intent ignoreIntent = new Intent();
    ignoreIntent.setAction("co.vanir.indecentxposure.IGNORE_LIKELY_FUNK");

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_stat_solve_problems).setContentTitle(title).setContentText(text)
            .setPriority(NotificationCompat.PRIORITY_MAX).setTicker(ticker)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(text).setBigContentTitle(title)
                    .setSummaryText(res.getString(R.string.summary_thanks)))
            .addAction(0, res.getString(R.string.action_remove),
                    PendingIntent.getActivity(context, 0, removeIntent, PendingIntent.FLAG_UPDATE_CURRENT))
            .addAction(0, res.getString(R.string.action_accept_consequences),
                    PendingIntent.getBroadcast(context, 0, ignoreIntent, PendingIntent.FLAG_CANCEL_CURRENT));

    notify(context, builder.build(), true);
}

From source file:com.google.android.gms.common.internal.C1339l.java

public static String m4742a(Context context, int i) {
    Resources resources = context.getResources();
    switch (i) {//from  w  ww  .j av a2 s. c om
    case GoogleMap.MAP_TYPE_NORMAL /*1*/:
        return resources.getString(C1095b.common_google_play_services_install_title);
    case GoogleMap.MAP_TYPE_SATELLITE /*2*/:
        return resources.getString(C1095b.common_google_play_services_update_title);
    case GoogleMap.MAP_TYPE_TERRAIN /*3*/:
        return resources.getString(C1095b.common_google_play_services_enable_title);
    case GoogleMap.MAP_TYPE_HYBRID /*4*/:
    case C1096c.MapAttrs_liteMode /*6*/:
    case C1096c.MapAttrs_cameraMaxZoomPreference /*18*/:
        return null;
    case C1096c.MapAttrs_cameraZoom /*5*/:
        Log.e("GoogleApiAvailability",
                "An invalid account was specified when connecting. Please provide a valid account.");
        return C1339l.m4743a(context, "common_google_play_services_invalid_account_title");
    case C1096c.MapAttrs_uiCompass /*7*/:
        Log.e("GoogleApiAvailability", "Network error occurred. Please retry request later.");
        return C1339l.m4743a(context, "common_google_play_services_network_error_title");
    case C1096c.MapAttrs_uiRotateGestures /*8*/:
        Log.e("GoogleApiAvailability", "Internal error occurred. Please see logs for detailed information");
        return null;
    case C1096c.MapAttrs_uiScrollGestures /*9*/:
        Log.e("GoogleApiAvailability", "Google Play services is invalid. Cannot recover.");
        return null;
    case C1096c.MapAttrs_uiTiltGestures /*10*/:
        Log.e("GoogleApiAvailability", "Developer error occurred. Please see logs for detailed information");
        return null;
    case C1096c.MapAttrs_uiZoomControls /*11*/:
        Log.e("GoogleApiAvailability", "The application is not licensed to the user.");
        return null;
    case C1096c.MapAttrs_ambientEnabled /*16*/:
        Log.e("GoogleApiAvailability",
                "One of the API components you attempted to connect to is not available.");
        return null;
    case C1096c.MapAttrs_cameraMinZoomPreference /*17*/:
        Log.e("GoogleApiAvailability", "The specified account could not be signed in.");
        return C1339l.m4743a(context, "common_google_play_services_sign_in_failed_title");
    case C1096c.MapAttrs_latLngBoundsSouthWestLongitude /*20*/:
        Log.e("GoogleApiAvailability",
                "The current user profile is restricted and could not use authenticated features.");
        return C1339l.m4743a(context, "common_google_play_services_restricted_profile_title");
    default:
        Log.e("GoogleApiAvailability", "Unexpected error code " + i);
        return null;
    }
}

From source file:Main.java

public static String resolveString(Context context, Resources res, String string) {
    if (string.startsWith("@")) {
        String subs = string.substring(1, string.length());
        String[] parts = subs.split("/");
        int id = res.getIdentifier(parts[1], parts[0], context.getPackageName());
        if (id == 0x0) {
            return string;
        }//  ww  w  .j a  v a  2s.  c  o m
        return res.getString(id);
    }
    return string;
}

From source file:com.example.nwilde.myfirstapp.settingsactivity.SettingsFragment.java

public static String getDefaultDir(Resources resources) {
    File outDir = FileUtils.getFileStorageDir(resources.getString(R.string.app_name));
    return outDir.getPath();
}

From source file:com.google.android.gms.common.internal.zzt.java

@Nullable
private static String a(final Context context, final String s) {
    while (true) {
        final int identifier;
        Label_0114: {//from   w  w w  . j  a v  a 2s. c  o  m
            synchronized (zzt.a) {
                final String s2 = zzt.a.get(s);
                String string;
                if (s2 != null) {
                    // monitorexit(zzt.a)
                    string = s2;
                } else {
                    final Resources remoteResource = GooglePlayServicesUtil.getRemoteResource(context);
                    if (remoteResource == null) {
                        // monitorexit(zzt.a)
                        string = null;
                    } else {
                        identifier = remoteResource.getIdentifier(s, "string", "com.google.android.gms");
                        if (identifier != 0) {
                            break Label_0114;
                        }
                        final String value = String.valueOf(s);
                        String concat;
                        if (value.length() != 0) {
                            concat = "Missing resource: ".concat(value);
                        } else {
                            concat = new String("Missing resource: ");
                        }
                        Log.w("GoogleApiAvailability", concat);
                        // monitorexit(zzt.a)
                        string = null;
                    }
                }
                return string;
            }
        }
        final Resources resources;
        String string = resources.getString(identifier);
        if (TextUtils.isEmpty((CharSequence) string)) {
            final String value2 = String.valueOf(s);
            String concat2;
            if (value2.length() != 0) {
                concat2 = "Got empty resource: ".concat(value2);
            } else {
                concat2 = new String("Got empty resource: ");
            }
            Log.w("GoogleApiAvailability", concat2);
            // monitorexit(simpleArrayMap)
            string = null;
            return string;
        }
        zzt.a.put(s, string);
        // monitorexit(simpleArrayMap)
        return string;
    }
}

From source file:com.android.messaging.sms.SmsStorageStatusManager.java

/**
 * Post sms storage low notification/*from   w w w.  ja v a2  s .co  m*/
 */
private static void postStorageLowNotification() {
    final Context context = Factory.get().getApplicationContext();
    final Resources resources = context.getResources();
    final PendingIntent pendingIntent = UIIntents.get().getPendingIntentForLowStorageNotifications(context);

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setContentTitle(resources.getString(R.string.sms_storage_low_title))
            .setTicker(resources.getString(R.string.sms_storage_low_notification_ticker))
            .setSmallIcon(R.drawable.ic_failed_light).setPriority(Notification.PRIORITY_DEFAULT)
            .setOngoing(true) // Can't be swiped off
            .setAutoCancel(false) // Don't auto cancel
            .setContentIntent(pendingIntent);

    final NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(builder);
    bigTextStyle.bigText(resources.getString(R.string.sms_storage_low_text));
    final Notification notification = bigTextStyle.build();

    final NotificationManagerCompat notificationManager = NotificationManagerCompat
            .from(Factory.get().getApplicationContext());

    notificationManager.notify(getNotificationTag(), PendingIntentConstants.SMS_STORAGE_LOW_NOTIFICATION_ID,
            notification);
}