List of usage examples for android.util Log w
public static int w(String tag, Throwable tr)
From source file:com.arellomobile.android.push.DeviceFeature2_5.java
static void sendAppOpen(Context context) { final Map<String, Object> data = new HashMap<String, Object>(); data.putAll(RequestHelper.getSendAppOpenData(context, NetworkUtils.PUSH_VERSION)); Log.w(TAG, "Try To sent AppOpen"); NetworkUtils.NetworkResult res = new NetworkUtils.NetworkResult(-1, null); Exception exception = new Exception(); for (int i = 0; i < NetworkUtils.MAX_TRIES; ++i) { try {//from w w w . j a va2 s . c om res = NetworkUtils.makeRequest(data, APP_OPEN); if (200 == res.getResultCode()) { Log.w(TAG, "Send AppOpen success"); return; } } catch (Exception e) { exception = e; } } Log.e(TAG, "ERROR: Try To sent AppOpen " + exception.getMessage() + ". Response = " + res.getResultData(), exception); }
From source file:org.kegbot.app.util.Downloader.java
/** * Downloads and returns a URL as a {@link Bitmap}. * * @param url the image to download//from w w w. j av a2 s . c om * @return a new {@link Bitmap}, or {@code null} if any error occurred */ public static Bitmap downloadBitmap(String url) { final HttpClient client = new DefaultHttpClient(); final HttpGet getRequest = new HttpGet(url); try { HttpResponse response = client.execute(getRequest); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Log.w(LOG_TAG, "Error " + statusCode + " while retrieving bitmap from " + url); return null; } final HttpEntity entity = response.getEntity(); if (entity != null) { InputStream inputStream = null; try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 2; inputStream = entity.getContent(); return BitmapFactory.decodeStream(inputStream, null, options); } finally { if (inputStream != null) { inputStream.close(); } entity.consumeContent(); } } } catch (IOException e) { getRequest.abort(); Log.w(LOG_TAG, "I/O error while retrieving bitmap from " + url, e); } catch (IllegalStateException e) { getRequest.abort(); Log.w(LOG_TAG, "Incorrect URL: " + url); } catch (Exception e) { getRequest.abort(); Log.w(LOG_TAG, "Error while retrieving bitmap from " + url, e); } finally { if ((client instanceof AndroidHttpClient)) { ((AndroidHttpClient) client).close(); } } return null; }
From source file:Main.java
public static int getSuVersionCode() { Process process = null;//from w ww . jav a2 s . co m String inLine = null; try { process = Runtime.getRuntime().exec("sh"); DataOutputStream os = new DataOutputStream(process.getOutputStream()); BufferedReader is = new BufferedReader( new InputStreamReader(new DataInputStream(process.getInputStream())), 64); os.writeBytes("su -v\n"); // We have to hold up the thread to make sure that we're ready to read // the stream, using increments of 5ms makes it return as quick as // possible, and limiting to 1000ms makes sure that it doesn't hang for // too long if there's a problem. for (int i = 0; i < 400; i++) { if (is.ready()) { break; } try { Thread.sleep(5); } catch (InterruptedException e) { Log.w(TAG, "Sleep timer got interrupted..."); } } if (is.ready()) { inLine = is.readLine(); if (inLine != null && Integer.parseInt(inLine.substring(0, 1)) > 2) { inLine = null; os.writeBytes("su -V\n"); inLine = is.readLine(); if (inLine != null) { return Integer.parseInt(inLine); } } else { return 0; } } else { os.writeBytes("exit\n"); } } catch (IOException e) { Log.e(TAG, "Problems reading current version.", e); return 0; } finally { if (process != null) { process.destroy(); } } return 0; }
From source file:org.thoughtcrime.securesms.mms.MmsDownloadHelper.java
private static byte[] makeRequest(MmsConnectionParameters connectionParameters, String url) throws ClientProtocolException, IOException { try {/*w ww. j a v a 2 s.c o m*/ HttpClient client = constructHttpClient(connectionParameters); URI hostUrl = new URI(url); HttpHost target = new HttpHost(hostUrl.getHost(), hostUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME); HttpRequest request = new HttpGet(url); request.setParams(client.getParams()); request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic"); HttpResponse response = client.execute(target, request); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) throw new IOException("Non-successful HTTP response: " + status.getReasonPhrase()); return parseResponse(response.getEntity()); } catch (URISyntaxException use) { Log.w("MmsDownlader", use); throw new IOException("Bad URI syntax"); } }
From source file:com.norman0406.slimgress.API.GameEntity.GameEntityBase.java
public static GameEntityBase createByJSON(JSONArray json) throws JSONException { if (json.length() != 3) { Log.e("GameEntityBase", "invalid array size"); return null; }//w ww . j a v a 2 s . c om JSONObject item = json.getJSONObject(2); // create entity GameEntityBase newEntity = null; if (item.has("edge")) newEntity = new GameEntityLink(json); else if (item.has("capturedRegion")) newEntity = new GameEntityControlField(json); else if (item.has("portalV2")) newEntity = new GameEntityPortal(json); else if (item.has("resource") || item.has("resourceWithLevels") || item.has("modResource")) newEntity = new GameEntityItem(json); else { // unknown game entity Log.w("GameEntityBase", "unknown game entity"); } return newEntity; }
From source file:org.fdroid.enigtext.mms.MmsDownloadHelper.java
private static byte[] makeRequest(Context context, MmsConnectionParameters connectionParameters, String url) throws IOException { AndroidHttpClient client = null;//from w w w. ja va 2 s .co m try { client = constructHttpClient(context, connectionParameters); URI targetUrl = new URI(url.trim()); HttpHost target = new HttpHost(targetUrl.getHost(), targetUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME); HttpGet request = new HttpGet(url.trim()); request.setParams(client.getParams()); request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic"); HttpResponse response = client.execute(target, request); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) throw new IOException("Non-successful HTTP response: " + status.getReasonPhrase()); return parseResponse(response.getEntity()); } catch (URISyntaxException use) { Log.w("MmsDownloadHelper", use); throw new IOException("Couldn't parse URI"); } finally { if (client != null) client.close(); } }
From source file:com.distimo.sdk.Utils.java
static Map<String, String> keyValueStringToMap(String query) { if (Utils.DEBUG) { Log.i(TAG, "keyValueStringToMap()"); }// w ww .ja va 2s .com // Create Map to store the parameters Map<String, String> result = new HashMap<String, String>(); // Parse the query string, extracting the relevant data String[] params = query.split("&"); // $NON-NLS-1$ for (String param : params) { String[] pair = param.split("="); // $NON-NLS-1$ if (pair.length == 2) { if (Utils.DEBUG) { Log.i(TAG, "Found " + pair[0] + "=" + pair[1]); } result.put(pair[0], pair[1]); } else { if (Utils.DEBUG) { Log.w(TAG, "Skipping " + param); } } } return result; }
From source file:at.bitfire.davdroid.log.LogcatHandler.java
@Override public void publish(LogRecord r) { String text = getFormatter().format(r); int level = r.getLevel().intValue(); int end = text.length(); for (int pos = 0; pos < end; pos += MAX_LINE_LENGTH) { String line = text.substring(pos, NumberUtils.min(pos + MAX_LINE_LENGTH, end)); if (level >= Level.SEVERE.intValue()) Log.e(r.getLoggerName(), line); else if (level >= Level.WARNING.intValue()) Log.w(r.getLoggerName(), line); else if (level >= Level.CONFIG.intValue()) Log.i(r.getLoggerName(), line); else if (level >= Level.FINER.intValue()) Log.d(r.getLoggerName(), line); else/*from w w w .j av a 2 s .c o m*/ Log.v(r.getLoggerName(), line); } }
From source file:com.intel.iotkitlib.LibModules.AuthorizationManagement.AuthorizationToken.java
public static void parseAndStoreAuthorizationToken(String response, int responseCode) throws JSONException { if (responseCode != 200) { Log.d(TAG, "invalid response for token request"); return;//from ww w . j a v a2 s .c o m } final String token = AuthorizationToken.parseAuthorizationTokenJson(new JSONObject(response)); //store token value to shared prefs storeToken(token); //IotKit.getInstance().authorizaionKey = token; //checks the validity of token Authorization authorization = new Authorization(new RequestStatusHandler() { @Override public void readResponse(int responseCode, String response) { try { if (responseCode != 200) { Log.w(TAG, "invalid token or responseCode"); return; } //store token associated details to shared prefs storeTokenInfo(response); } catch (JSONException e) { e.printStackTrace(); } } }); authorization.validateAuthToken(); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.UnknownObj.java
@Override public void handleDirectMessage(Context context, Contact from, JSONObject msg) { Log.w("musubi", "Received unknown obj: " + msg); }