List of usage examples for android.content Context getString
@NonNull public final String getString(@StringRes int resId)
From source file:cm.aptoide.pt.util.NetworkUtils.java
public static String getUserAgentString(Context mctx) { SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(mctx); String myid = sPref.getString("myId", "NoInfo"); String myscr = sPref.getInt("scW", 0) + "x" + sPref.getInt("scH", 0); String partnerid = ""; if (ApplicationAptoide.PARTNERID != null) { partnerid = "PartnerID:" + ApplicationAptoide.PARTNERID + ";"; }//from w w w. j a v a 2s. c om return "aptoide-" + mctx.getString(R.string.ver_str) + ";" + Configs.TERMINAL_INFO + ";" + myscr + ";id:" + myid + ";" + sPref.getString(Configs.LOGIN_USER_LOGIN, "") + ";" + partnerid; }
From source file:com.entertailion.android.slideshow.utils.Utils.java
/** * Get the Android version of the app.//w ww . jav a2 s.c o m * * @param context * @return */ public static final String getVersion(Context context) { String versionString = context.getString(R.string.unknown_build); try { PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); versionString = info.versionName; } catch (Exception e) { // do nothing } return versionString; }
From source file:com.saulcintero.moveon.osm.OSMHelper.java
public static OAuthConsumer GetOSMAuthConsumer(Context ctx) { OAuthConsumer consumer = null;/* w w w. j a v a2s . co m*/ try { int osmConsumerKey = ctx.getResources().getIdentifier("osm_consumerkey", "string", ctx.getPackageName()); int osmConsumerSecret = ctx.getResources().getIdentifier("osm_consumersecret", "string", ctx.getPackageName()); consumer = new CommonsHttpOAuthConsumer(ctx.getString(osmConsumerKey), ctx.getString(osmConsumerSecret)); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); String osmAccessToken = prefs.getString("osm_accesstoken", ""); String osmAccessTokenSecret = prefs.getString("osm_accesstokensecret", ""); if (osmAccessToken != null && osmAccessToken.length() > 0 && osmAccessTokenSecret != null && osmAccessTokenSecret.length() > 0) { consumer.setTokenWithSecret(osmAccessToken, osmAccessTokenSecret); } } catch (Exception e) { } return consumer; }
From source file:com.twitt4droid.Twitt4droid.java
/** * Deletes the current twitter user.//from w ww .j ava2 s .c o m * * @param context the application context. */ public static void deleteCurrentUser(Context context) { Resources.getPreferences(context).edit().remove(context.getString(R.string.twitt4droid_user_key)).commit(); }
From source file:com.twitt4droid.Twitt4droid.java
/** * Deletes any authentication information from {@code SharedPreferences}. * /*from w w w . j a v a2s . c o m*/ * @param context the application context. */ public static void deleteAuthenticationInfo(Context context) { Resources.getPreferences(context).edit().remove(context.getString(R.string.twitt4droid_oauth_token_key)) .remove(context.getString(R.string.twitt4droid_oauth_secret_key)) .remove(context.getString(R.string.twitt4droid_user_is_logged_in_key)).commit(); }
From source file:com.nextgis.maplibui.util.ControlHelper.java
public static String getSyncTime(Context context, long timeStamp) { String date = new SimpleDateFormat("dd MMM", Locale.getDefault()).format(new Date(timeStamp)); String time = new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date(timeStamp)); return String.format(context.getString(R.string.last_sync_time), date, time); }
From source file:be.ac.ucl.lfsab1509.llncampus.ExternalAppUtility.java
/** * Start the Google Maps application and navigate the user to the specified location. * /* ww w. j a va 2 s . com*/ * @param lat * Destination latitude. * @param lon * Destination longitude. * @param c * Current context. */ public static void startNavigation(float lat, float lon, Context c) { try { Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?daddr=" + lat + "," + lon + "&dirflg=w")); intent.setComponent( new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity")); c.startActivity(intent); } catch (ActivityNotFoundException e) { // If we don't have Google Maps Log.e("ExternalAppUtility", c.getString(R.string.no_google_maps)); Toast t = Toast.makeText(LLNCampus.getContext().getApplicationContext(), R.string.no_google_maps, Toast.LENGTH_LONG); t.setGravity(Gravity.CENTER, 0, 0); t.show(); } }
From source file:com.twitt4droid.Twitt4droid.java
/** * Gets the current twitter user.//from w ww .jav a 2 s .com * * @param context the application context. * @return the current twitter user if exists; otherwise {@code null}. */ public static User getCurrentUser(Context context) { String json = Resources.getPreferences(context).getString(context.getString(R.string.twitt4droid_user_key), null); return UserJSONImpl.fromJSON(json); }
From source file:cn.suishen.email.LegacyConversions.java
/** * Infer mailbox type from mailbox name. Used by MessagingController (for live folder sync). *///from w w w . jav a 2s .c o m public static synchronized int inferMailboxTypeFromName(Context context, String mailboxName) { if (sServerMailboxNames.size() == 0) { // preload the hashmap, one time only sServerMailboxNames.put(context.getString(R.string.mailbox_name_server_inbox).toLowerCase(), Mailbox.TYPE_INBOX); sServerMailboxNames.put(context.getString(R.string.mailbox_name_server_outbox).toLowerCase(), Mailbox.TYPE_OUTBOX); sServerMailboxNames.put(context.getString(R.string.mailbox_name_server_drafts).toLowerCase(), Mailbox.TYPE_DRAFTS); sServerMailboxNames.put(context.getString(R.string.mailbox_name_server_trash).toLowerCase(), Mailbox.TYPE_TRASH); sServerMailboxNames.put(context.getString(R.string.mailbox_name_server_sent).toLowerCase(), Mailbox.TYPE_SENT); sServerMailboxNames.put(context.getString(R.string.mailbox_name_server_junk).toLowerCase(), Mailbox.TYPE_JUNK); } if (mailboxName == null || mailboxName.length() == 0) { return Mailbox.TYPE_MAIL; } String lowerCaseName = mailboxName.toLowerCase(); Integer type = sServerMailboxNames.get(lowerCaseName); if (type != null) { return type; } return Mailbox.TYPE_MAIL; }
From source file:mp.paschalis.App.java
/** * @param status/*ww w .j a va 2 s.com*/ */ public static String getBookStatusString(int status, Context c) { switch (status) { case App.BOOK_STATE_USER_RENTED: return c.getString(R.string.rented); case App.BOOK_STATE_USER_AVAILABLE: return c.getString(R.string.available); case App.BOOK_STATE_USER_NO_RENTAL: return c.getString(R.string.dontLent); case App.BOOK_STATE_USER_OTHER: return c.getString(R.string.otherDontLent); case App.BOOK_STATE_USER_DONT_OWNS: return c.getString(R.string.dontOwn); default: return c.getString(R.string.wrongStatusCode); } }