List of usage examples for android.util Log isLoggable
public static native boolean isLoggable(String tag, int level);
From source file:net.vleu.par.android.rpc.Transceiver.java
/** * This method may block while a network request completes, and must never * be made from the main thread. It requests a new GoogleAuthToken. * /*from ww w . j a v a 2 s .co m*/ * @param account * The account to fetch an auth token for * @return A token associated with this account * @throws OperationCanceledException * if the request was canceled for any reason, including the * user canceling a credential request * @throws AuthenticatorException * if the authenticator failed to respond * @throws IOException * if the authenticator experienced an I/O problem creating a * new auth token, usually because of network trouble */ private GoogleAuthToken blockingGetNewAuthToken() throws OperationCanceledException, AuthenticatorException, IOException { final AccountManager am = AccountManager.get(this.context); final String authTokenStr = am.blockingGetAuthToken(this.account, APPENGINE_TOKEN_TYPE, true); if (Log.isLoggable(TAG, Log.INFO)) Log.i(TAG, "Got a new GoogleAuthToken for account: " + this.account.name + ": " + authTokenStr); if (authTokenStr == null) throw new AuthenticatorException("Could not get an auth token"); else return new GoogleAuthToken(authTokenStr); }
From source file:com.phonemetra.lockclock.weather.YahooWeatherProvider.java
@Override public WeatherInfo getWeatherInfo(Location location, boolean metric) { String language = getLanguage(); String params = String.format(Locale.US, "\"%f %f\" and locale=\"%s\"", location.getLatitude(), location.getLongitude(), language); String url = URL_PLACEFINDER + Uri.encode(params); JSONObject results = fetchResults(url); if (results == null) { return null; }/*from w w w . jav a 2s .c o m*/ try { JSONObject result = results.getJSONObject("Result"); String woeid = result.getString("woeid"); String city = null; for (String name : PLACE_NAMES) { if (!result.isNull(name)) { city = result.getString(name); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, String.format(Locale.US, "Placefinder for location %f %f " + "matched %s using %s", location.getLatitude(), location.getLongitude(), city, name)); } break; } } // The city name in the placefinder result is HTML encoded :-( if (city != null) { city = Html.fromHtml(city).toString(); } else { Log.w(TAG, "Can not resolve place name for " + location); } Log.d(TAG, "Resolved location " + location + " to " + city + " (" + woeid + ")"); WeatherInfo info = getWeatherInfo(woeid, city, metric); if (info != null) { return info; } } catch (JSONException e) { Log.e(TAG, "Received malformed placefinder data (location=" + location + ", lang=" + language + ")", e); } return null; }
From source file:com.playtang.commonnavigation.login.PlayTangLoginActivity.java
private Bundle getMergedOptions() { // Read activity metadata from AndroidManifest.xml ActivityInfo activityInfo = null;/*from w ww . ja va2s . c o m*/ try { activityInfo = getPackageManager().getActivityInfo(this.getComponentName(), PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { if (Parse.getLogLevel() <= Parse.LOG_LEVEL_ERROR && Log.isLoggable(LOG_TAG, Log.WARN)) { Log.w(LOG_TAG, e.getMessage()); } } // The options specified in the Intent (from PlayTangLoginBuilder) will // override any duplicate options specified in the activity metadata Bundle mergedOptions = new Bundle(); if (activityInfo != null && activityInfo.metaData != null) { mergedOptions.putAll(activityInfo.metaData); } if (getIntent().getExtras() != null) { mergedOptions.putAll(getIntent().getExtras()); } return mergedOptions; }
From source file:com.spark.percent.PercentLayoutHelper.java
private void invokeMethod(String methodName, int widthHint, int heightHint, View view, Class<?> clazz, PercentLayoutInfo.PercentVal percentVal) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, methodName + " ==> " + percentVal); if (percentVal != null) { Method setMaxWidthMethod = clazz.getMethod(methodName, int.class); setMaxWidthMethod.setAccessible(true); int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode); setMaxWidthMethod.invoke(view, (int) (base * percentVal.percent)); }// w w w. ja v a 2s. co m }
From source file:com.google.android.car.kitchensink.radio.RadioTestFragment.java
private void initializeRadio() { mRadioManager = (RadioManager) getContext().getSystemService(Context.RADIO_SERVICE); if (mRadioManager == null) { throw new IllegalStateException("RadioManager could not be loaded."); }/*from w w w . j av a 2 s . co m*/ int status = mRadioManager.listModules(mModules); if (status != RadioManager.STATUS_OK) { throw new IllegalStateException("Load modules failed with status: " + status); } if (mModules.size() == 0) { throw new IllegalStateException("No radio modules on device."); } boolean isDebugLoggable = Log.isLoggable(TAG, Log.DEBUG); // Load the possible radio bands. For now, just accept FM and AM bands. for (RadioManager.BandDescriptor band : mModules.get(0).getBands()) { if (isDebugLoggable) { Log.d(TAG, "loading band: " + band.toString()); } if (mFmDescriptor == null && band.isFmBand()) { mFmDescriptor = (RadioManager.FmBandDescriptor) band; } if (mAmDescriptor == null && band.isAmBand()) { mAmDescriptor = (RadioManager.AmBandDescriptor) band; } } if (mFmDescriptor == null && mAmDescriptor == null) { throw new IllegalStateException("No AM and FM radio bands could be loaded."); } mFmConfig = new RadioManager.FmBandConfig.Builder(mFmDescriptor).setStereo(true).build(); mAmConfig = new RadioManager.AmBandConfig.Builder(mAmDescriptor).setStereo(true).build(); }
From source file:com.example.android.wearable.agendadata.MainActivity.java
@Override public void onConnectionSuspended(int cause) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onConnectionSuspended(): Cause id: " + cause); }//from www. j a v a2s. c o m }
From source file:android.percent.support.PercentLayoutHelper.java
private void invokeMethod(String methodName, int widthHint, int heightHint, View view, Class clazz, PercentLayoutInfo.PercentVal percentVal) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, methodName + " ==> " + percentVal); if (percentVal != null) { Method setMaxWidthMethod = clazz.getMethod(methodName, int.class); setMaxWidthMethod.setAccessible(true); int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode); setMaxWidthMethod.invoke(view, (int) (base * percentVal.percent)); }// ww w .j a va2 s. c om }
From source file:com.icenler.lib.view.support.percentlayout.PercentLayoutHelper.java
/** * Constructs a PercentLayoutInfo from attributes associated with a View. Call this method from * {@code LayoutParams(Context c, AttributeSet attrs)} constructor. *//*from w w w. jav a 2s. c o m*/ public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) { PercentLayoutInfo info = null; TypedArray array = context.obtainStyledAttributes(attrs, com.zhy.android.percent.support.R.styleable.PercentLayout_Layout); info = setWidthAndHeightVal(array, info); info = setMarginRelatedVal(array, info); info = setTextSizeSupportVal(array, info); info = setMinMaxWidthHeightRelatedVal(array, info); info = setPaddingRelatedVal(array, info); Log.d(TAG, "constructed: " + info); array.recycle(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "constructed: " + info); } return info; }
From source file:com.infine.android.devoxx.service.RestService.java
private void loadRemoteData() throws HandlerException { final long startRemote = System.currentTimeMillis(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mApplicationContext); // gestion des schedules int localScheduleVersion = prefs.getInt(PREFS_SCHEDULE_VERSION, 0); int lastScheduleVersion = VersionReader.getVersion(SERVER_PATH_SCHEDULE_VERSION); if (localScheduleVersion < lastScheduleVersion) { mRemoteExecutor.executeGet(SERVER_PATH_SCHEDULE, new JsonScheduleHandler(mApplicationContext, PREFS_SCHEDULE_VERSION, lastScheduleVersion)); }/*from ww w . j ava 2 s .c om*/ // gestion des sessions int localSessionVersion = prefs.getInt(PREFS_SESSION_VERSION, 0); int lastSessionVersion = VersionReader.getVersion(SERVER_PATH_SESSION_VERSION); if (localSessionVersion < lastSessionVersion) { mRemoteExecutor.executeGet(SERVER_PATH_SESSION, new JsonSessionHandler(mApplicationContext, PREFS_SESSION_VERSION, lastSessionVersion)); } // speaker management int localSpeakerVersion = prefs.getInt(PREFS_SPEAKER_VERSION, 0); int lastSpeakerVersion = VersionReader.getVersion(SERVER_PATH_SPEAKER_VERSION); if (localSpeakerVersion < lastSpeakerVersion) { mRemoteExecutor.executeGet(SERVER_PATH_SPEAKER, new JsonSpeakerHandler(mApplicationContext, PREFS_SPEAKER_VERSION, lastSpeakerVersion)); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "remote sync took " + (System.currentTimeMillis() - startRemote) + "ms"); } }
From source file:com.example.android.wearable.agendadata.MainActivity.java
@Override public void onConnectionFailed(ConnectionResult result) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Disconnected from Google Api Service"); }/*from ww w. ja v a2s .c o m*/ if (mResolvingError) { // Already attempting to resolve an error. return; } else if (result.hasResolution()) { try { mResolvingError = true; result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR); } catch (IntentSender.SendIntentException e) { // There was an error with the resolution intent. Try again. mResolvingError = false; mGoogleApiClient.connect(); } } else { mResolvingError = false; } }