List of usage examples for android.util Log w
public static int w(String tag, Throwable tr)
From source file:com.deltadna.android.sdk.Params.java
/** * Puts the key/value pair into these parameters. * * @param key the key//from www .j a va2s . co m * @param value the value * * @return this {@link Params} instance * * @throws IllegalArgumentException if the {@code key} is null or empty */ public Params put(String key, Object value) { Preconditions.checkString(key, "key cannot be null or empty"); if (value == null) { Log.w(BuildConfig.LOG_TAG, "null value for key: " + key); } try { json.put(key, value); } catch (JSONException e) { throw new IllegalArgumentException(e); } return this; }
From source file:it.agileday.utils.HttpRestUtil.java
public static Bitmap httpGetBitmap(String url) { final HttpClient client = new DefaultHttpClient(); final HttpGet getRequest = new HttpGet(url); try {/*from w w w . j av a 2s . c o m*/ HttpResponse response = client.execute(getRequest); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Log.w(TAG, "Error " + statusCode + " while retrieving bitmap from " + url); return null; } final HttpEntity entity = response.getEntity(); if (entity != null) { InputStream inputStream = null; try { inputStream = entity.getContent(); final Bitmap bitmap = BitmapFactory.decodeStream(inputStream); return bitmap; } finally { if (inputStream != null) { inputStream.close(); } entity.consumeContent(); } } } catch (Exception e) { getRequest.abort(); Log.w(TAG, "Error while retrieving bitmap from " + url, e); } return null; }
From source file:com.galois.qrstream.lib.DecodeThread.java
@Override public void run() { Job message;//w ww. j a v a 2 s . com try { message = (Job) receiver.decodeQRSerializable(cameraManager); Log.w(Constants.APP_TAG, "DecodeThread received " + message.getData().length + " bytes, " + "mimetype: " + message.getMimeType()); Intent i = buildIntent(message); context.startActivity(Intent.createChooser(i, "Open with")); } catch (ReceiveException e) { Log.e(Constants.APP_TAG, "DecodeThread failed to read message. " + e.getMessage()); } catch (IOException e) { Log.e(Constants.APP_TAG, "Could not store data to temp file." + e.getMessage()); } finally { // The receiver has finished. Clear the UI. uiHandle.sendMessage(new Message()); } }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.service.UpdateMbtoolWithRootTask.java
@Override public void execute() { // If we've reached this point, then the SignedExec upgrade should have failed, but just in // case, we'll retry that method. boolean ret;/*from www . ja v a 2 s .c om*/ if ((ret = MbtoolConnection.replaceViaSignedExec(getContext()))) { Log.v(TAG, "Successfully updated mbtool with SignedExec method"); } else { Log.w(TAG, "Failed to update mbtool with SignedExec method"); if ((ret = MbtoolConnection.replaceViaRoot(getContext()))) { Log.v(TAG, "Successfully updated mbtool with root method"); } else { Log.w(TAG, "Failed to update mbtool with root method"); } } Log.d(TAG, "Attempting mbtool connection after update"); if (ret) { MbtoolConnection conn = null; try { conn = new MbtoolConnection(getContext()); MbtoolInterface iface = conn.getInterface(); Log.d(TAG, "mbtool was updated to " + iface.getVersion()); } catch (Exception e) { Log.e(TAG, "Failed to connect to mbtool", e); ret = false; } finally { IOUtils.closeQuietly(conn); } } synchronized (mStateLock) { mSuccess = ret; sendReply(); mFinished = true; } }
From source file:com.avanade.C2DMReceiver.java
@Override public void onRegistrered(Context context, String registrationId) { Log.w("C2DMReceiver-onRegistered", registrationId); String urlString = "https://mobileapi.whatsnewat.com/WNADataService.svc/RegisterAndroidDevice?deviceToken='" + registrationId + "'&deviceID='" + LoginScreen.androidDevice_id + "'"; HttpGet httpGet = new HttpGet(urlString); // set header parameters with user-provided credentials LoginScreen.httpFlag = 1;//from w w w . j a va2 s .c om HttpGetRequest token = new HttpGetRequest(); httpGet.setHeader(Constants.emailId, LoginScreen.statEmailId); httpGet.setHeader(Constants.companyKey, LoginScreen.statCompKey); // obtain response XML from the server String xml = token.performGetRequest(httpGet); Intent dBUpdateIntent = new Intent(getBaseContext(), DatabaseUpdate.class); dBUpdateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); dBUpdateIntent.putExtra("DeviceId", registrationId); getApplication().startActivity(dBUpdateIntent); // Intent dialogIntent = new Intent(getBaseContext(), NextPage.class); // dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // getApplication().startActivity(dialogIntent); }
From source file:es.upm.dit.gsi.noticiastvi.gtv.account.DeleteThread.java
@Override public void run() { DefaultHttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(Constant.SERVER_URL + "?action=" + ACTION + "&identifier=" + id); try {// w w w . ja va 2 s. co m HttpResponse getResponse = client.execute(get); final int statusCode = getResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Log.w(getClass().getSimpleName(), "Error " + statusCode); handler.sendEmptyMessage(RESULT_ERROR); return; } HttpEntity getResponseEntity = getResponse.getEntity(); String res = inputStreamToString(getResponseEntity.getContent()); if (res != null && res.equals("ok")) { handler.sendEmptyMessage(RESULT_OK); } else { handler.sendEmptyMessage(RESULT_ERROR); } } catch (Exception e) { handler.sendEmptyMessage(RESULT_ERROR); Log.e("ERROR", e.getMessage()); } }
From source file:me.xiaopan.android.gohttp.HttpRequestHandler.java
@Override public void run() { if (httpRequest.isCanceled()) { httpRequest.finish();/*from ww w . j ava 2 s. com*/ new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : " + "; " + httpRequest.getUrl()); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Started : " + "; " + httpRequest.getUrl()); boolean isCache = httpRequest.getCacheConfig() != null; ReentrantLock reentrantLock = null; if (isCache) { reentrantLock = httpRequest.getGoHttp().getSyncManager() .getLockByCacheId(httpRequest.getCacheConfig().getId()); reentrantLock.lock(); if (httpRequest.isCanceled()) { httpRequest.finish(); new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : ??" + "; " + httpRequest.getUrl()); reentrantLock.unlock(); return; } } boolean isRefreshCache = isCache && httpRequest.getCacheConfig().isRefreshCache(); boolean isContinueCallback = true; HttpResponse httpResponse = null; // ?? if (isCache && httpRequest.getGoHttp().getCacheManager().isHasAvailableCache(httpRequest)) { if (httpRequest.isCanceled()) { httpRequest.finish(); new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : ?" + "; " + httpRequest.getUrl()); reentrantLock.unlock(); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Cache : ?" + "; " + httpRequest.getUrl()); // ?Http? httpResponse = httpRequest.getGoHttp().getCacheManager().readHttpResponseFromCache(httpRequest); if (httpRequest.isCanceled()) { httpRequest.finish(); new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : ?" + "; " + httpRequest.getUrl()); reentrantLock.unlock(); return; } if (httpResponse != null) { try { Object responseObject = httpRequest.getResponseHandler().handleResponse(httpRequest, httpResponse); if (responseObject == null) { throw new Exception("response object is null"); } // ??? isContinueCallback = isRefreshCache && httpRequest.getCacheConfig().isRefreshCallback(); if (!(responseObject instanceof HttpRequest.Failure) && httpRequest.getResponseHandleCompletedAfterListener() != null) { //noinspection unchecked Object response = httpRequest.getResponseHandleCompletedAfterListener() .onResponseHandleAfter(httpRequest, httpResponse, responseObject, true, isContinueCallback); if (response != null) { responseObject = response; } } if (httpRequest.isCanceled()) { httpRequest.finish(); new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : ??" + "; " + httpRequest.getUrl()); reentrantLock.unlock(); return; } // ????? if (!isRefreshCache) { httpRequest.finish(); } if (responseObject instanceof HttpRequest.Failure) { new FailedRunnable(httpRequest, httpResponse, (HttpRequest.Failure) responseObject, true, isContinueCallback).execute(); } else { new CompletedRunnable(httpRequest, httpResponse, responseObject, true, isContinueCallback) .execute(); } // ????? if (!isRefreshCache) { if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Completed : ???" + "; " + httpRequest.getUrl()); reentrantLock.unlock(); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Cache : ??" + "; " + httpRequest.getUrl()); } catch (Throwable e) { e.printStackTrace(); if (httpRequest.isCanceled()) { httpRequest.finish(); new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : ?Http??" + "; " + httpRequest.getUrl()); reentrantLock.unlock(); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.e(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Failed : ?Http??" + "; " + httpRequest.getUrl()); new FailedRunnable(httpRequest, httpResponse, new HttpRequest.Failure(e), true, isContinueCallback).execute(); } } } // ?? try { httpResponse = httpRequest.getGoHttp().getNetManager().getHttpResponse(httpRequest); } catch (Throwable e) { e.printStackTrace(); releaseConnect(httpResponse); httpRequest.finish(); if (httpRequest.isCanceled()) { if (isContinueCallback) { new CancelRunnable(httpRequest).execute(); } if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : ?Http??" + "; " + httpRequest.getUrl()); if (reentrantLock != null) reentrantLock.unlock(); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.e(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Failed : ?Http??" + "; " + httpRequest.getUrl()); if (isContinueCallback) { new FailedRunnable(httpRequest, httpResponse, new HttpRequest.Failure(e), false, false).execute(); } if (reentrantLock != null) reentrantLock.unlock(); return; } if (httpRequest.isCanceled()) { releaseConnect(httpResponse); httpRequest.finish(); new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : ?Http?" + "; " + httpRequest.getUrl()); if (reentrantLock != null) reentrantLock.unlock(); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Net : ?Http??" + "; " + httpRequest.getUrl()); // Http? if (isCache && httpRequest.getResponseHandler().canCache(httpResponse)) { try { httpRequest.getGoHttp().getCacheManager().saveHttpResponseToCache(httpRequest, httpResponse); } catch (IOException e) { e.printStackTrace(); releaseConnect(httpResponse); httpRequest.finish(); if (httpRequest.isCanceled()) { if (isContinueCallback) { new CancelRunnable(httpRequest).execute(); } if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : Http??" + "; " + httpRequest.getUrl()); reentrantLock.unlock(); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Failed : Http??" + "; " + httpRequest.getUrl()); if (isContinueCallback) { new FailedRunnable(httpRequest, httpResponse, new HttpRequest.Failure(e), false, false) .execute(); } reentrantLock.unlock(); return; } if (httpRequest.isCanceled()) { httpRequest.finish(); new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : Http?" + "; " + httpRequest.getUrl()); reentrantLock.unlock(); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Cache : Http??" + "; " + httpRequest.getUrl()); } // ??? if (!isContinueCallback) { httpRequest.finish(); if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Completed : ??" + "; " + httpRequest.getUrl()); reentrantLock.unlock(); return; } // ?? Object responseObject; try { responseObject = httpRequest.getResponseHandler().handleResponse(httpRequest, httpResponse); if (responseObject == null) { throw new Exception("response object is null"); } // ??? if (!(responseObject instanceof HttpRequest.Failure) && httpRequest.getResponseHandleCompletedAfterListener() != null) { //noinspection unchecked Object response = httpRequest.getResponseHandleCompletedAfterListener() .onResponseHandleAfter(httpRequest, httpResponse, responseObject, false, false); if (response != null) { responseObject = response; } } } catch (Throwable e) { e.printStackTrace(); releaseConnect(httpResponse); httpRequest.finish(); if (httpRequest.isCanceled()) { new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : ??Http??" + "; " + httpRequest.getUrl()); if (reentrantLock != null) reentrantLock.unlock(); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.e(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Failed : ??Http??" + "; " + httpRequest.getUrl()); new FailedRunnable(httpRequest, httpResponse, new HttpRequest.Failure(e), false, false).execute(); if (reentrantLock != null) reentrantLock.unlock(); return; } if (httpRequest.isCanceled()) { releaseConnect(httpResponse); httpRequest.finish(); new CancelRunnable(httpRequest).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.w(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Canceled : ?Http?" + "; " + httpRequest.getUrl()); if (reentrantLock != null) reentrantLock.unlock(); return; } if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Net : ?Http?" + "; " + httpRequest.getUrl()); // if (responseObject instanceof HttpRequest.Failure) { HttpRequest.Failure failure = (HttpRequest.Failure) responseObject; new FailedRunnable(httpRequest, httpResponse, failure, false, false).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.e(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Failed : " + failure.toString() + "; " + httpRequest.getUrl()); } else { new CompletedRunnable(httpRequest, httpResponse, responseObject, false, false).execute(); if (httpRequest.getGoHttp().isDebugMode()) Log.d(GoHttp.LOG_TAG, httpRequest.getName() + "; " + "Completed : ?" + "; " + httpRequest.getUrl()); } httpRequest.finish(); if (reentrantLock != null) reentrantLock.unlock(); }
From source file:com.google.samples.apps.friendlyping.gcm.MyGcmListenerService.java
private void digestData(Bundle data) throws JSONException { final String action = data.getString("action"); Log.d(TAG, "Action: " + action); if (action == null) { Log.w(TAG, "onMessageReceived: Action was null, skipping further processing."); return;// w w w. ja va2 s . c om } Intent broadcastIntent = new Intent(action); switch (action) { case GcmAction.SEND_CLIENT_LIST: final ArrayList<Pinger> pingers = getPingers(data); broadcastIntent.putParcelableArrayListExtra(IntentExtras.PINGERS, pingers); break; case GcmAction.BROADCAST_NEW_CLIENT: Pinger newPinger = getNewPinger(data); broadcastIntent.putExtra(IntentExtras.NEW_PINGER, newPinger); break; case GcmAction.PING_CLIENT: Ping newPing = getNewPing(data); broadcastIntent.putExtra(IntentExtras.NEW_PING, newPing); break; } LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent); }
From source file:com.idean.atthack.network.RequestHelper.java
public RequestHelper(Context context) { mContext = context;//from w w w . j a v a 2 s . c o m if (!Pref.VIN.contains(mContext) || !Pref.USERNAME.contains(mContext) || !Pref.PASSWORD.contains(mContext)) { Log.w(TAG, "Missing required preference values: vin, pin, username"); } Log.d(TAG, "Found username " + Pref.USERNAME.get(context) + "Pin " + Pref.PIN.get(context)); }
From source file:com.github.luluvise.droid_utils.http.DefaultBackOffRequired.java
@Override public boolean isRequired(@Nonnull HttpResponse response) { final int statusCode = response.getStatusCode(); switch (statusCode) { case 0:/* ww w . j a v a 2s . c o m*/ /* * No HTTP response (may be caused by a Google's library fault) * TODO: check if the new google-http-java-client still causes it */ if (DroidConfig.DEBUG) { Log.e(TAG, "Backoff required for '0' response status code to: " + response.getRequest().getUrl()); } return true; case HttpStatus.SC_CONFLICT: // server-side conflict, retry with backoff if (DroidConfig.DEBUG) { Log.w(TAG, "Backoff required for '409 - Conflict' response status code to: " + response.getRequest().getUrl()); } return true; case HttpStatus.SC_BAD_GATEWAY: // server unavailable, or too busy, retry with backoff if (DroidConfig.DEBUG) { Log.w(TAG, "Handle '502 - Bad Gateway' response status code to: " + response.getRequest().getUrl()); } return true; default: return false; } }