List of usage examples for android.content Context getString
@NonNull public final String getString(@StringRes int resId)
From source file:altermarkive.uploader.Config.java
public Config(Sampler sampler) { this.sampler = sampler; Context context = sampler.context(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); String url = preferences.getString(context.getString(R.string.uploading), null); Upload.instance().initiate(url);/*from ww w . j ava2 s. co m*/ }
From source file:de.ub0r.android.websms.connector.smspilotru.ConnectorSMSpilotRu.java
/** * {@inheritDoc}// ww w . j av a 2s .c o m */ @Override public ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.connector_smspilot_name); ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(// . context.getString(R.string.connector_smspilot_author)); c.setBalance(null); c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS); c.addSubConnector("smspilot.ru", name, SubConnectorSpec.FEATURE_CUSTOMSENDER); return c; }
From source file:com.lillicoder.newsblurry.feeds.FeedRepository.java
/** * Restores feeds saved in storage and returns * a map of the restored feeds keyed by feed ID. * @return {@link Map} of restored {@link Feed} keyed by feed ID. *///from w ww . j a va2 s .c om public Map<Integer, Feed> restoreFeeds() { Map<Integer, Feed> feedsById = new HashMap<Integer, Feed>(); Context context = this.getContext(); SharedPreferences preferences = this.getSharedPreferences(); String feedsJsonText = preferences.getString(context.getString(R.string.preference_persistedFeeds), null); if (feedsJsonText != null) { try { JSONArray feedsArrayJson = new JSONArray(feedsJsonText); FeedParser parser = new FeedParser(context); feedsById = parser.parseFeedsById(feedsArrayJson); } catch (JSONException e) { Log.w(TAG, WARNING_FAILED_TO_RESTORE_FEEDS_JSON, e); } } return feedsById; }
From source file:com.mikecorrigan.trainscorekeeper.ScoreEvent.java
public String formatHistory(Context context, int score) { String action = String.format(history, null, value); Log.e(TAG, "history=" + history + ", action=" + action + ", value=" + value); String format = String.format(context.getString(R.string.history_entry), playerName, action, score); return format; }
From source file:de.ub0r.android.websms.connector.smsclub.ConnectorSmsClub.java
/** * {@inheritDoc}/*from w w w . j a va2 s .c o m*/ */ @Override public final ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.connector_smsclub_name); ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(// . context.getString(R.string.connector_smsclub_author)); c.setBalance(null); // balance update without sending is currently not supported by the api, // so it also not supported by the implementation. c.setCapabilities(ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS | ConnectorSpec.CAPABILITIES_UPDATE); c.addSubConnector(TAG, name, SubConnectorSpec.FEATURE_MULTIRECIPIENTS); return c; }
From source file:com.lillicoder.newsblurry.feeds.FeedRepository.java
/** * Saves the given map of feeds to storage. *///from w w w . j av a 2s .c o m public void saveFeeds(Map<Integer, Feed> feedsById) { // Create a feeds JSON object we can write to storage. JSONArray feedsJson = new JSONArray(); for (Feed feed : feedsById.values()) { try { feedsJson.put(feed.toJson()); } catch (JSONException e) { Log.w(TAG, String.format(WARNING_FAILED_TO_SAVE_FEED_TO_JSON, feed.getId()), e); } } // Write data to storage. Context context = this.getContext(); SharedPreferences preferences = this.getSharedPreferences(); Editor editor = preferences.edit(); editor.putString(context.getString(R.string.preference_persistedFeeds), feedsJson.toString()); editor.commit(); }
From source file:com.nextgis.maplibui.mapui.NGWVectorLayerUI.java
@Override public void showEditForm(Context context, long featureId, GeoGeometry geometry) { if (mFields == null) { Toast.makeText(context, context.getString(R.string.error_layer_not_inited), Toast.LENGTH_SHORT).show(); return;/*w w w . ja va 2 s. c om*/ } boolean isGeometryChanged = geometry != null; //get geometry if (geometry == null && featureId != Constants.NOT_FOUND) { geometry = getGeometryForId(featureId); } Intent intent; //check custom form File form = new File(mPath, ConstantsUI.FILE_FORM); if (form.exists()) { //show custom form intent = new Intent(context, FormBuilderModifyAttributesActivity.class); intent.putExtra(KEY_FORM_PATH, form); } else { //if not exist show standard form intent = new Intent(context, ModifyAttributesActivity.class); } intent.putExtra(KEY_LAYER_ID, getId()); intent.putExtra(KEY_FEATURE_ID, featureId); intent.putExtra(KEY_GEOMETRY_CHANGED, isGeometryChanged); if (null != geometry) intent.putExtra(KEY_GEOMETRY, geometry); ((Activity) context).startActivityForResult(intent, MODIFY_REQUEST); }
From source file:com.notifry.android.remote.BackendClient.java
public BackendClient(Context context, String accountName) { this.context = context; this.accountName = accountName; this.backendName = "https://" + context.getString(R.string.backend_url); }
From source file:org.intermine.app.net.request.post.FetchListResultsRequest.java
public FetchListResultsRequest(Context ctx, String mineName, String listType, String listName, int start, int size) { super(ListItems.class, ctx, null, null, null, mineName); mListName = listName;/*from ww w . j ava2 s . co m*/ String template = ctx.getString(R.string.list_query); Map<String, List<String>> typeFieldsMap = getStorage().getTypeFields(mineName); List<String> typeFields = typeFieldsMap.get(listType); String columns = Strs.EMPTY_STRING; if (null != typeFields) { columns = Strs.join(typeFields, " "); } mQuery = String.format(template, columns, listType, mListName); mStart = start; mSize = size; setRetryPolicy(new NoRetryPolicy()); }
From source file:com.scvngr.levelup.core.net.RequestUtilsTest.java
/** * Test {@link com.scvngr.levelup.core.net.RequestUtils#addApiKeyToRequestQueryParams}. *///from ww w. j ava 2s . co m @SmallTest public void testAddApiKeyToRequestQueryParams() { final Map<String, String> expected = new HashMap<String, String>(); final Map<String, String> params = new HashMap<String, String>(); final Context context = NullUtils.nonNullContract(getContext()); expected.put(RequestUtils.PARAM_API_KEY, context.getString(R.string.levelup_api_key)); RequestUtils.addApiKeyToRequestQueryParams(context, params); assertEquals(expected.toString(), params.toString()); }