List of usage examples for android.content Context getString
@NonNull public final String getString(@StringRes int resId)
From source file:com.ryan.ryanreader.common.General.java
public static void quickToast(final Context context, final int textRes) { quickToast(context, context.getString(textRes)); }
From source file:com.kakao.KakaoLink.java
/** * ?? API singleton KakaoLink ./*from w ww . java 2 s . co m*/ */ public static KakaoLink getKakaoLink(final Context context) throws KakaoParameterException { if (singltonKakaoLink != null) return singltonKakaoLink; if (appKey == null) appKey = Utility.getMetadata(context, APP_KEY_PROPERTY); if (TextUtils.isEmpty(appKey)) throw new KakaoParameterException(context.getString(string.com_kakao_alert_appKey)); else { appVer = String.valueOf(Utility.getAppVersion(context)); appPackageName = Utility.getAppPackageName(context); singltonKakaoLink = new KakaoLink(); return singltonKakaoLink; } }
From source file:com.nextgis.maplibui.util.ControlHelper.java
public static String getPercentValue(Context context, int stringLabel, float value) { return context.getString(stringLabel) + ": " + ((int) value * 100 / 255) + "%"; }
From source file:com.creationgroundmedia.popularmovies.sync.MovieSyncAdapter.java
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) { Account account = getSyncAccount(context); String authority = context.getString(R.string.content_authority); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // we can enable inexact timers in our periodic sync SyncRequest request = new SyncRequest.Builder().syncPeriodic(syncInterval, flexTime) .setSyncAdapter(account, authority).setExtras(new Bundle()).build(); ContentResolver.requestSync(request); } else {// w w w . j av a 2 s .co m ContentResolver.addPeriodicSync(account, authority, new Bundle(), syncInterval); } }
From source file:com.grarak.kerneladiutor.utils.kernel.cpu.Temperature.java
public static String getGPU(Context context) { double temp = getGPUTemp(); boolean useFahrenheit = Utils.useFahrenheit(context); if (useFahrenheit) temp = Utils.celsiusToFahrenheit(temp); return Utils.roundTo2Decimals(temp) + context.getString(useFahrenheit ? R.string.fahrenheit : R.string.celsius); }
From source file:com.grarak.kerneladiutor.utils.kernel.cpu.Temperature.java
public static String getCPU(Context context) { double temp = getCPUTemp(); boolean useFahrenheit = Utils.useFahrenheit(context); if (useFahrenheit) temp = Utils.celsiusToFahrenheit(temp); return Utils.roundTo2Decimals(temp) + context.getString(useFahrenheit ? R.string.fahrenheit : R.string.celsius); }
From source file:com.example.igorklimov.popularmoviesdemo.sync.SyncAdapter.java
private static void onAccountCreated(Account newAccount, Context context) { Log.d(LOG_TAG, "CREATED NEW ACCOUNT"); SyncAdapter.configurePeriodicSync(context, SYNC_INTERVAL, FLEX_TIME); ContentResolver.setSyncAutomatically(newAccount, context.getString(R.string.content_authority), true); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); preferences.edit().putLong(context.getString(R.string.last_update), System.currentTimeMillis()).apply(); SyncAdapter.syncImmediately(context); }
From source file:minghai.nisesakura.SimpleBottleHelper.java
/** * Prepare the internal User-Agent string for use. This requires a * {@link Context} to pull the package name and version number for this * application.//from www. j a v a 2 s . c om */ public static void prepareUserAgent(Context context) { try { // Read package name and version number from manifest PackageManager manager = context.getPackageManager(); PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0); sUserAgent = String.format(context.getString(R.string.template_user_agent), info.packageName, info.versionName); Log.d(TAG, "sUserAgent = " + sUserAgent); } catch (NameNotFoundException e) { Log.e(TAG, "Couldn't find package information in PackageManager", e); } }
From source file:com.beesham.popularmovies.sync.MoviesSyncAdapter.java
private static Account getSyncAccount(Context context) { AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.sync_account_type)); if (accountManager.getPassword(newAccount) == null) { if (!accountManager.addAccountExplicitly(newAccount, "", null)) { return null; }//from ww w . j a v a 2 s . c om onAccountCreated(newAccount, context); } return newAccount; }
From source file:com.joelapenna.foursquared.appwidget.stats.FoursquareHelper.java
/** * Prepare the internal User-Agent string for use. This requires a * {@link android.content.Context} to pull the package name and version number for this * application./*from ww w . j a va2 s .co m*/ */ public static void prepareUserAgent(Context context) { try { // Read package name and version number from manifest PackageManager manager = context.getPackageManager(); PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0); sUserAgent = String.format(context.getString(R.string.stats_widget_template_user_agent), info.versionName, info.packageName); } catch (NameNotFoundException e) { Log.e(TAG, "Couldn't find package information in PackageManager", e); } }