Example usage for android.util Log w

List of usage examples for android.util Log w

Introduction

In this page you can find the example usage for android.util Log w.

Prototype

public static int w(String tag, Throwable tr) 

Source Link

Usage

From source file:mobisocial.musubi.util.UriImage.java

public UriImage(Context context, Uri uri) {
    if ((null == context) || (null == uri)) {
        throw new IllegalArgumentException();
    }/*from   w  w  w  . j ava2s  .  com*/

    mRotation = PhotoTaker.rotationForImage(context, uri);
    String scheme = uri.getScheme();
    if (scheme.equals("content")) {
        try {
            initFromContentUri(context, uri);
        } catch (Exception e) {
            Log.w(TAG, "last-ditch image params");
            mPath = uri.getPath();
            mContentType = context.getContentResolver().getType(uri);
        }
    } else if (uri.getScheme().equals("file")) {
        initFromFile(context, uri);
    } else {
        mPath = uri.getPath();
    }

    mSrc = mPath.substring(mPath.lastIndexOf('/') + 1);

    if (mSrc.startsWith(".") && mSrc.length() > 1) {
        mSrc = mSrc.substring(1);
    }

    // Some MMSCs appear to have problems with filenames
    // containing a space.  So just replace them with
    // underscores in the name, which is typically not
    // visible to the user anyway.
    mSrc = mSrc.replace(' ', '_');

    mContext = context;
    mUri = uri;
}

From source file:es.deustotech.piramide.utils.net.GoogleLocalClient.java

public Vector<Point> getPoints() throws GoogleLocalException {
    final Vector<Point> points = new Vector<Point>();
    int position = 0;
    String start = "0";
    JSONArray pages;//  w  ww  .  j a  v a 2 s. co  m
    do {
        try {
            final URI baseURI = new URI(URI[0] + selection + URI[1] + String.valueOf(latitude) + URI[2]
                    + String.valueOf(longitude) + URI[3] + start);
            Log.w("GoogleLocalClient", baseURI.toURL().toString());
            final HttpEntity entity = RestClient.connect(baseURI.toURL().toString(), null);
            final String content = convertStreamToString(entity.getContent());
            final JSONObject jsonObj = new JSONObject(content);
            final JSONObject responseData = jsonObj.getJSONObject("responseData");
            final JSONObject cursor = responseData.getJSONObject("cursor");
            if (!cursor.has("pages"))
                break; // No pages, no results

            pages = cursor.getJSONArray("pages");
            position++;
            if (position < pages.length()) {
                final JSONObject nextPage = pages.getJSONObject(position);
                start = nextPage.getString("start");
            }

            final JSONArray results = responseData.getJSONArray("results");
            for (int i = 0; i < results.length(); ++i) {
                final JSONObject result = results.getJSONObject(i);
                final Point point = new Point(result.getString(Constants.JSON_TITLE),
                        result.getString(Constants.JSON_STREET), result.getString(Constants.JSON_LAT),
                        result.getString(Constants.JSON_LNG));
                points.add(point);
            }

        } catch (Exception e) {
            throw new GoogleLocalException(e.getMessage(), e);
        }
    } while (position < pages.length() && position < MAX_PAGES_TO_PARSE);

    Log.w("GoogleLocalClient", Integer.valueOf(points.size()).toString());

    return points;
}

From source file:cn.kang.base.crash.handler.SimpleMultipartEntity.java

public void writeLastBoundaryIfNeeds() {
    if (!isSetLast) {
        try {/*www  .  j a  va2 s.  c  o  m*/
            out.write(("\r\n--" + boundary + "--\r\n").getBytes());
        } catch (final IOException e) {
            Log.w(e.getMessage(), e);
        }
        isSetLast = true;
    }
}

From source file:com.tih.tihir.ConsumerIrManagerBase.java

@Override
public UUID cancelCommand() {
    Log.w(TAG, "cancelCommand() is not available on this device");
    return null;
}

From source file:com.shafiq.mytwittle.URLFetch.java

public static InputStream retrieveStream(String url) {
    DefaultHttpClient client = new DefaultHttpClient();
    HttpGet getRequest = new HttpGet(url);
    try {/*from  w  ww  . j a  v  a 2  s . c  o m*/
        HttpResponse getResponse = client.execute(getRequest);
        final int statusCode = getResponse.getStatusLine().getStatusCode();

        if (statusCode != HttpStatus.SC_OK) {
            Log.w("abtApp", "Error " + statusCode + " for URL " + url);
            return null;
        }

        HttpEntity getResponseEntity = getResponse.getEntity();
        return getResponseEntity.getContent();
    } catch (IOException e) {
        getRequest.abort();
        Log.w("abtApp", "Error for URL " + url, e);
    }
    return null;
}

From source file:com.worthed.googleplus.HttpUtils.java

/**
 * Send post request.//from  w  w w  .  j a v a2  s .c  o  m
 * @param url 
 * @param params
 * @return It's a error if result start with "Error:".
 */
public String doPost(String url, List<NameValuePair> params) {
    HttpClient httpClient = getHttpClient();
    /* HTTPPost */
    HttpPost httpRequest = new HttpPost(url);
    String strResult = ERROR_PREFIX;

    try {
        /* ? */
        httpRequest.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
        /* ??? */
        HttpResponse httpResponse = httpClient.execute(httpRequest);
        /* ??200 ok */
        if (httpResponse.getStatusLine().getStatusCode() == 200) {
            /* ? */
            strResult = EntityUtils.toString(httpResponse.getEntity());
        } else {
            strResult += httpResponse.getStatusLine().toString();
        }
    } catch (ClientProtocolException e) {
        strResult += e.getMessage().toString();
        e.printStackTrace();
        return null;
    } catch (IOException e) {
        strResult += e.getMessage().toString();
        e.printStackTrace();
        return null;
    } catch (Exception e) {
        strResult += e.getMessage().toString();
        e.printStackTrace();
        return null;
    }
    Log.w(TAG, strResult);
    return strResult;
}

From source file:pl.lewica.util.FileUtil.java

public static boolean fetchAndSaveImage(String sourceUrl, String destinationPath, boolean overwrite)
        throws IOException {
    File destinationFile = new File(destinationPath);
    if (destinationFile.exists() && !overwrite) {
        return false;
    }//from   w w  w.j  ava2  s .  c o m

    BufferedInputStream bis = null;
    FileOutputStream fos = null;

    try {
        URL url = new URL(sourceUrl);
        // See http://stackoverflow.com/questions/3498643/dalvik-message-default-buffer-size-used-in-bufferedinputstream-constructor-it/7516554#7516554
        int bufferSize = 8192;
        bis = new BufferedInputStream(url.openStream(), bufferSize);
        ByteArrayBuffer bab = new ByteArrayBuffer(50);

        int current = 0;
        while ((current = bis.read()) != -1) {
            bab.append((byte) current);
        }

        fos = new FileOutputStream(destinationFile);
        fos.write(bab.toByteArray());
        fos.close();
    } catch (MalformedURLException e) {
        throw e;
    } catch (IOException e) {
        throw e;
    } finally {
        if (fos != null) {
            try {
                fos.close();
            } catch (IOException ioe) {
                // This issue can be safely skipped but there's no harm in logging it
                Log.w("FileUtil", "Unable to close file output stream for " + sourceUrl);
            }
        }
        if (bis != null) {
            try {
                bis.close();
            } catch (IOException ioe) {
                // This issue can be safely skipped but there's no harm in logging it
                Log.w("FileUtil", "Unable to close buffered input stream for " + sourceUrl);
            }
        }
    }

    return true;
}

From source file:com.norman0406.slimgress.API.Item.ItemBase.java

public static ItemBase createByJSON(JSONArray json) throws JSONException {
    if (json.length() != 3) {
        Log.e("ItemBase", "invalid array size");
        return null;
    }/*from  ww  w . jav a  2 s  .  c o m*/

    JSONObject item = json.getJSONObject(2);

    JSONObject itemResource = null;
    if (item.has("resource"))
        itemResource = item.getJSONObject("resource");
    else if (item.has("resourceWithLevels"))
        itemResource = item.getJSONObject("resourceWithLevels");
    else if (item.has("modResource"))
        itemResource = item.getJSONObject("modResource");

    // create item
    ItemBase newItem = null;

    String itemType = itemResource.getString("resourceType");
    if (itemType.equals(ItemPortalKey.getNameStatic()))
        newItem = new ItemPortalKey(json);
    else if (itemType.equals(ItemWeaponXMP.getNameStatic()))
        newItem = new ItemWeaponXMP(json);
    else if (itemType.equals(ItemWeaponUltraStrike.getNameStatic()))
        newItem = new ItemWeaponUltraStrike(json);
    else if (itemType.equals(ItemResonator.getNameStatic()))
        newItem = new ItemResonator(json);
    else if (itemType.equals(ItemModShield.getNameStatic()))
        newItem = new ItemModShield(json);
    else if (itemType.equals(ItemPowerCube.getNameStatic()))
        newItem = new ItemPowerCube(json);
    else if (itemType.equals(ItemMedia.getNameStatic()))
        newItem = new ItemMedia(json);
    else if (itemType.equals(ItemModForceAmp.getNameStatic()))
        newItem = new ItemModForceAmp(json);
    else if (itemType.equals(ItemModMultihack.getNameStatic()))
        newItem = new ItemModMultihack(json);
    else if (itemType.equals(ItemModLinkAmp.getNameStatic()))
        newItem = new ItemModLinkAmp(json);
    else if (itemType.equals(ItemModTurret.getNameStatic()))
        newItem = new ItemModTurret(json);
    else if (itemType.equals(ItemModHeatsink.getNameStatic()))
        newItem = new ItemModHeatsink(json);
    else if (itemType.equals(ItemFlipCard.getNameStatic()))
        newItem = new ItemFlipCard(json);
    else {
        // unknown resource type
        Log.w("Item", "unknown resource type: " + itemType);
    }

    return newItem;
}

From source file:com.tingtingapps.securesms.mms.OutgoingLegacyMmsConnection.java

@Override
public @Nullable SendConf send(@NonNull byte[] pduBytes) throws UndeliverableMessageException {
    try {//from www.  ja v  a  2 s  .  co m
        MmsRadio radio = MmsRadio.getInstance(context);

        if (isCdmaDevice()) {
            Log.w(TAG, "Sending MMS directly without radio change...");
            try {
                return send(pduBytes, false, false);
            } catch (IOException e) {
                Log.w(TAG, e);
            }
        }

        Log.w(TAG, "Sending MMS with radio change and proxy...");
        radio.connect();

        try {
            try {
                return send(pduBytes, true, true);
            } catch (IOException e) {
                Log.w(TAG, e);
            }

            Log.w(TAG, "Sending MMS with radio change and without proxy...");

            try {
                return send(pduBytes, true, false);
            } catch (IOException ioe) {
                Log.w(TAG, ioe);
                throw new UndeliverableMessageException(ioe);
            }
        } finally {
            radio.disconnect();
        }

    } catch (MmsRadioException e) {
        Log.w(TAG, e);
        throw new UndeliverableMessageException(e);
    }

}

From source file:com.ddpclient.spiovesan.ddpclient.LogService.java

@Override
public void onLocationChanged(Location l) {
    location = l;/*from w w w . j a  va  2 s  . c om*/
    int lat = (int) (location.getLatitude());
    int lng = (int) (location.getLongitude());
    Log.w("LogPositionApp", "Latitude: " + String.valueOf(lat));
    Log.w("LogPositionApp", "Longitude: " + String.valueOf(lng));
}