List of usage examples for android.util Log w
public static int w(String tag, String msg, Throwable tr)
From source file:nl.mpcjanssen.simpletask.util.Util.java
public static void closeStream(Closeable stream) { if (stream != null) { try {/* ww w. j av a 2s . co m*/ stream.close(); } catch (IOException e) { Log.w(TAG, "Close stream exception", e); } } }
From source file:es.upm.dit.gsi.noticiastvi.gtv.item.FavoriteThread.java
private boolean doFavorite() { if (!TEST) {/* w w w . j a v a 2 s .c om*/ DefaultHttpClient client = new DefaultHttpClient(); HttpGet getRequest = new HttpGet(Constant.SERVER_URL + "?action=" + action + "&identifier=" + user + "&content=" + id + "&preference=1"); try { client.execute(getRequest); return true; } catch (IOException e) { getRequest.abort(); Log.w(getClass().getSimpleName(), "Error", e); return false; } } else { Log.i("favorite", "TEST_MODE"); return true; } }
From source file:com.facebook.notifications.internal.appevents.AppEventsLogger.java
public AppEventsLogger(@NonNull Context context) { try {/*w ww .ja v a2 s. c o m*/ Class<?> loggerClass = Class.forName("com.facebook.appevents.AppEventsLogger"); Method instantiateMethod = loggerClass.getMethod("newLogger", Context.class); fbSDKLogMethod = loggerClass.getMethod("logEvent", String.class, Bundle.class); fbSDKLogger = instantiateMethod.invoke(null, context); } catch (Exception ex) { Log.w(LOG_TAG, "Failed to initialize AppEventsLogger. " + "Did you forget to include the Facebook SDK in your application?", ex); } }
From source file:com.loopj.android.http.sample.JsonStreamerSample.java
@Override public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) { RequestParams params = new RequestParams(); params.setUseJsonStreamer(true);//from w ww . ja v a 2s . c o m JSONObject body; if (isRequestBodyAllowed() && (body = getBodyTextAsJSON()) != null) { try { Iterator keys = body.keys(); Log.d(LOG_TAG, "JSON data:"); while (keys.hasNext()) { String key = (String) keys.next(); Log.d(LOG_TAG, " " + key + ": " + body.get(key)); params.put(key, body.get(key).toString()); } } catch (JSONException e) { Log.w(LOG_TAG, "Unable to retrieve a JSON value", e); } } return client.post(this, URL, headers, params, RequestParams.APPLICATION_JSON, responseHandler); }
From source file:com.todotxt.todotxttouch.util.Util.java
public static void closeStream(Closeable stream) { if (stream != null) { try {// w w w.j a v a 2 s . co m stream.close(); stream = null; } catch (IOException e) { Log.w(TAG, "Close stream exception", e); } } }
From source file:com.lightbox.android.operations.CachedOperation.java
@Override public final void executeAsync(OperationListener<T> listener) { List<T> resultList = null; try {//from w w w .j av a2 s . c o m resultList = executeLocalOperationSync(); } catch (Throwable t) { Log.w(TAG, "Failed to retrieve data from cache", t); } if (resultList != null && !resultList.isEmpty()) { DebugLog.d(TAG, "Getting result from cache."); // Call back on main thread if (listener != null) { listener.onSuccess(this, resultList); } } if (!mRetrieveFromLocalDataOnly && mIsDataTooOld) { // Proceed with normal operation execution super.executeAsync(listener); } }
From source file:com.amazon.s3.util.BinaryUtils.java
/** * Converts a Base64-encoded string to the original byte data. * /*from w w w . jav a 2s . c om*/ * @param b64Data * a Base64-encoded string to decode. * * @return bytes decoded from a Base64 string. */ public static byte[] fromBase64(String b64Data) { byte[] decoded; try { decoded = Base64.decodeBase64(b64Data.getBytes(DEFAULT_ENCODING)); } catch (UnsupportedEncodingException uee) { // Shouldn't happen if the string is truly Base64 encoded. Log.w(TAG, "Tried to Base64-decode a String with the wrong encoding: ", uee); decoded = Base64.decodeBase64(b64Data.getBytes()); } return decoded; }
From source file:curt.android.book.NetworkWorker.java
public void run() { try {/*w w w.j ava 2 s. c o m*/ // These return a JSON result which describes if and where the query was found. This API may // break or disappear at any time in the future. Since this is an API call rather than a // website, we don't use LocaleManager to change the TLD. String uri; if (LocaleManager.isBookSearchUrl(isbn)) { int equals = isbn.indexOf('='); String volumeId = isbn.substring(equals + 1); uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + query; } else { uri = "http://www.google.com/books?vid=isbn" + isbn + "&jscmd=SearchWithinVolume2&q=" + query; } try { String content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON); JSONObject json = new JSONObject(content); Message message = Message.obtain(handler, R.id.search_book_contents_succeeded); message.obj = json; message.sendToTarget(); } catch (IOException ioe) { Message message = Message.obtain(handler, R.id.search_book_contents_failed); message.sendToTarget(); } } catch (JSONException je) { Log.w(TAG, "Error accessing book search", je); Message message = Message.obtain(handler, R.id.search_book_contents_failed); message.sendToTarget(); } }
From source file:com.google.zxing.client.android.book.NetworkWorker.java
@Override public void run() { try {//from w w w. jav a 2 s. c om // These return a JSON result which describes if and where the query was found. This API may // break or disappear at any time in the future. Since this is an API call rather than a // website, we don't use LocaleManager to change the TLD. String uri; if (LocaleManager.isBookSearchUrl(isbn)) { int equals = isbn.indexOf('='); String volumeId = isbn.substring(equals + 1); uri = "http://www.google.com/books?id=" + volumeId + "&jscmd=SearchWithinVolume2&q=" + query; } else { uri = "http://www.google.com/books?vid=isbn" + isbn + "&jscmd=SearchWithinVolume2&q=" + query; } try { String content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.JSON); JSONObject json = new JSONObject(content); Message message = Message.obtain(handler, R.id.search_book_contents_succeeded); message.obj = json; message.sendToTarget(); } catch (IOException ioe) { Message message = Message.obtain(handler, R.id.search_book_contents_failed); message.sendToTarget(); } } catch (JSONException je) { Log.w(TAG, "Error accessing book search", je); Message message = Message.obtain(handler, R.id.search_book_contents_failed); message.sendToTarget(); } }
From source file:fr.inria.ucn.collectors.AppDataUsageCollector.java
@Override public void run(Context c, long ts) { try {/*from w w w . j a v a 2 s . com*/ // data used per app JSONArray parray = new JSONArray(); File f = new File(PROC_UID_STAT); if (f.exists() && f.isDirectory() && f.canRead()) { for (String dir : f.list()) { parray.put(getProcInfo(c, Integer.parseInt(dir))); } } else { ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningAppProcessInfo pinfo : am.getRunningAppProcesses()) { parray.put(getProcInfo(c, pinfo.uid)); } } // done Helpers.sendResultObj(c, "app_data_usage", ts, new JSONObject().put("process_list", parray)); } catch (JSONException jex) { Log.w(Constants.LOGTAG, "failed to create json object", jex); } }