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:Main.java

/**
 * Encode a String of URL into UTF-8, and handles exception by returning a default value.
 * @param url The URL to encode//  www. j  a  v  a 2s.  c om
 */
public static String urlEncode(String url, String def) {
    try {
        return URLEncoder.encode(url, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        Log.w("Transit URL encode", "Unsupported encoding: " + e.getMessage());
        return def;
    }
}

From source file:Main.java

public static ZipInputStream getFileFromZip(InputStream zipFileStream) throws IOException {
    ZipInputStream zis = new ZipInputStream(zipFileStream);
    ZipEntry ze;//from w w  w .j  av a  2s.c o m
    while ((ze = zis.getNextEntry()) != null) {
        Log.w("AssetUtil", "extracting file: '" + ze.getName() + "'...");
        return zis;
    }
    return null;
}

From source file:Main.java

public static void iapAddProduct(String name, int ID, int type) {
    name = name.toLowerCase();/*from www .java2s  .  c  o m*/
    Log.w("IAB AddProduct", "Adding: " + name + " to ID: " + Integer.toString(ID));
    if (ID < 0 || ID >= MAX_PRODUCTS)
        return;
    g_iPurchaseProductStates[ID] = 0;
    g_sPurchaseProductNames[ID] = name;
    g_iPurchaseProductTypes[ID] = type;
    Log.w("IAB AddProduct", "Added: " + name);
    if (ID + 1 > g_iNumProducts)
        g_iNumProducts = ID + 1;
}

From source file:Main.java

/**
 * To add hack to .3gp file/*from ww  w.  ja  va2  s .c  o m*/
 * @param url
 * @return
 */
public static String getAudioMimeType(String url) {
    String type = null;
    String extension = MimeTypeMap.getFileExtensionFromUrl(url);
    Log.w("KKIM", " Sending File Extension = " + extension);
    if (extension != null) {
        if (extension.equalsIgnoreCase("3gp") || extension.equalsIgnoreCase("3gpp")) {
            if (is3gpFileAudio(url)) {
                type = "audio/3gpp";
            } else {
                MimeTypeMap mime = MimeTypeMap.getSingleton();
                type = mime.getMimeTypeFromExtension(extension);
            }
        } else {
            MimeTypeMap mime = MimeTypeMap.getSingleton();
            type = mime.getMimeTypeFromExtension(extension);
        }

        if (type.equalsIgnoreCase("application/ogg")) {
            type = "audio/ogg";
            Log.d("KKIM", "Formatting Audio File Type from application/ogg to audio/ogg");
        }
    }
    return type;
}

From source file:Main.java

public static Bitmap getVideoFrame(String videoPath, long frameTime) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();

    try {/* www. j a va2s  .  c  o m*/
        retriever.setDataSource(videoPath);
        return retriever.getFrameAtTime(frameTime, MediaMetadataRetriever.OPTION_CLOSEST);
    } catch (IllegalArgumentException ex) {
        Log.w("FFMPEG.MediaUtils", "illegal argument exception");

    } catch (RuntimeException ex) {
        Log.w("FFMPEG.MediaUtils", "error getting video frame");
    } finally {
        try {
            retriever.release();
        } catch (RuntimeException ex) {
        }
    }
    return null;
}

From source file:Main.java

public static int colorForString(String string) {
    try {//from   w  ww.  j a  v  a 2  s. com
        String colorString = "#" + string;
        int color = Color.parseColor(colorString);
        return color;
    } catch (NumberFormatException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        Log.w(TAG, "Color parsing error from string: " + string);
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

public static String getPrimaryAccountEmail(Context context) {
    AccountManager accountManager = AccountManager.get(context);
    Account[] accounts = accountManager.getAccountsByType("com.google");
    if (accounts == null || accounts.length == 0) {
        Log.w(LOG_PREFIX, "Could not find name of primary google account. Returning null");
        return null;
    } else {//from   w w  w  .j  a  va 2s .c o  m
        String name = accounts[0].name;
        Log.d(LOG_PREFIX, "Found " + accounts.length + " google accounts. Returning name:" + name);
        return name;
    }
}

From source file:Main.java

private static File getCacheDirImpl(Context c) {
    synchronized (sSync) {
        sCacheDir = new File(c.getFilesDir(), "cache");
        if (sCacheDir.exists() == false) {
            if (sCacheDir.mkdirs() == false) {
                Log.w(TAG, "Unable to create cache directory");
                return null;
            }//from w  w  w .  ja v  a 2s  .co m
        }
    }
    return sCacheDir;
}

From source file:Main.java

/**
 * Builds map from list of strings/*  ww  w. j  a va 2 s .  c om*/
 *
 * @param args key-value pairs for build a map. Must be a multiple of 2
 * @return Result map. If args not multiple of 2, last argument will be ignored
 */
public static Map<String, Object> mapFrom(Object... args) {
    if (args.length % 2 != 0) {
        Log.w("VKUtil", "Params must be paired. Last one is ignored");
    }
    LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(args.length / 2);
    for (int i = 0; i + 1 < args.length; i += 2) {
        if (!(args[i] instanceof String))
            Log.e("VK SDK", "Error while using mapFrom",
                    new InvalidParameterSpecException("Key must be string"));
        result.put((String) args[i], args[i + 1]);
    }
    return result;
}

From source file:Main.java

public static Long stringToLong(String str) {
    if (str == null) {
        return null;
    } else {/*  w  w w  .j  a  v  a 2 s .c om*/
        try {
            return Long.parseLong(str);
        } catch (NumberFormatException e) {
            try {
                Double d = Double.valueOf(str);
                if (d.doubleValue() > mMaxLong.doubleValue() + 1.0) {
                    Log.w(TAG, "Value " + d + " too large for long");
                    return null;
                }
                return Long.valueOf(d.longValue());
            } catch (NumberFormatException nfe2) {
                Log.w(TAG,
                        "Unable to interpret value " + str + " in field being "
                                + "converted to long, caught NumberFormatException <" + nfe2.getMessage()
                                + "> field discarded");
                return null;
            }
        }
    }
}