Example usage for android.util Log e

List of usage examples for android.util Log e

Introduction

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

Prototype

public static int e(String tag, String msg) 

Source Link

Document

Send an #ERROR log message.

Usage

From source file:Main.java

public static String getDefaultCurrencies(InputStream is) {

    Writer writer = new StringWriter();
    char[] buffer = new char[1024];
    try {/*from  www.  j a  v  a 2s .  c om*/
        Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        int n;
        while ((n = reader.read(buffer)) != -1) {
            writer.write(buffer, 0, n);
        }
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "loadCurrencies " + "Encoding error");
    } catch (IOException e) {
        Log.e(TAG, "loadCurrencies " + "IOException");
    } finally {
        try {
            is.close();
        } catch (IOException e) {
            Log.e(TAG, "loadCurrencies " + "IOException - close");
        }
    }
    return writer.toString();
}

From source file:Main.java

public static byte[] encrypt(byte[] ivBytes, byte[] keyBytes, byte[] textBytes) {
    try {/*www . ja va  2 s . c o m*/
        AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
        SecretKeySpec newKey = new SecretKeySpec(keyBytes, "AES");
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, newKey, ivSpec);
        return cipher.doFinal(textBytes);
    } catch (Exception e) {
        Log.e(TAG, "Error during encryption: " + e.toString());
        return errorbyte;
    }
}

From source file:Main.java

public static String getMetaValue(String metaName) {
    ApplicationInfo appInfo;/*from  w w w .j  a v a  2s  .c  om*/
    String metaValue = null;
    try {
        appInfo = APPLICATION_CONTEXT.getPackageManager()
                .getApplicationInfo(APPLICATION_CONTEXT.getPackageName(), PackageManager.GET_META_DATA);
        metaValue = appInfo.metaData.getString(metaName);
    } catch (NameNotFoundException e) {
        Log.e(TAG, e.getMessage());
    }
    return metaValue;
}

From source file:Main.java

public static void copyfile(File source, File dest) {
    try {//from  www .jav  a2 s  .c  o  m
        InputStream in = new FileInputStream(source);
        OutputStream out = new FileOutputStream(dest);
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        }
        in.close();
        out.close();
    } catch (FileNotFoundException e) {
        Log.e(TAG, e.getLocalizedMessage());
    } catch (IOException e) {
        Log.e(TAG, e.getLocalizedMessage());
    }
}

From source file:Main.java

public static void LOGE(final String tag, String message) {
    if (LOGGING_ENABLED) {
        Log.e(tag, message);
    }
}

From source file:Main.java

private static byte[] readELFHeadrIndentArray(File libFile) {
    if (libFile != null && libFile.exists()) {
        FileInputStream inputStream = null;
        try {/*ww w.  j av a  2s . c o  m*/
            inputStream = new FileInputStream(libFile);
            if (inputStream != null) {
                byte[] tempBuffer = new byte[16];
                int count = inputStream.read(tempBuffer, 0, 16);
                if (count == 16) {
                    return tempBuffer;
                } else {
                    if (LOGENABLE) {
                        Log.e("readELFHeadrIndentArray",
                                "Error: e_indent lenght should be 16, but actual is " + count);
                    }
                }
            }
        } catch (Throwable t) {
            if (LOGENABLE) {
                Log.e("readELFHeadrIndentArray", "Error:" + t.toString());
            }
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

    return null;
}

From source file:Main.java

public static void killProcess(String packageName) {
    String processId = "";
    try {//  w  ww.j a  v a  2 s.c o m
        Runtime r = Runtime.getRuntime();
        Process p = r.exec("ps");
        BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String inline;
        while ((inline = br.readLine()) != null) {
            if (packageName != null) {
                if (inline.contains(packageName)) {
                    break;
                }
            } else {
                Log.e("PvTorrent_proc", "packageName is null");
            }

        }
        br.close();
        Log.i("PvTorrent_proc", "inline" + inline);
        if (inline != null) {

            StringTokenizer processInfoTokenizer = new StringTokenizer(inline);
            int count = 0;
            while (processInfoTokenizer.hasMoreTokens()) {
                count++;
                processId = processInfoTokenizer.nextToken();
                if (count == 2) {
                    break;
                }
            }
            Log.i("PvTorrent_proc", "kill process : " + processId);
            r.exec("kill -9 " + processId);
        }
    } catch (IOException ex) {
        Log.e("PvTorrent_proc", "kill" + ex.getStackTrace());
    }
}

From source file:Main.java

public static BitmapDrawable loadAppIcon(String iconPath, Context context) {
    try {/*from  w w w .  ja  v a  2 s .  c o m*/
        Bitmap bitmap = null;
        Bitmap newBitmap = null;
        if (iconPath != null && !"".equals(iconPath)) {
            bitmap = BitmapFactory.decodeFile(iconPath);
        }

        if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) {
            Log.e("RecommAppsUtils", iconPath + " is not exist");
            return null;
        }
        int densityDpi = context.getResources().getDisplayMetrics().densityDpi;
        float scale = densityDpi / STANDARD_DENSITYDPI;
        newBitmap = zoomBitmap(bitmap, (int) (APP_ICON_WIDTH * scale), (int) (APP_ICON_HEIGHT * scale));
        // Log.d("RecommAppsUtils", "densityDpi value : " + densityDpi);
        return new BitmapDrawable(context.getResources(), newBitmap);
    } catch (OutOfMemoryError error) {
        error.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static void LOGE(final String text) {
    Log.e(LOG_TAG, text);
}

From source file:Main.java

public static String stripNonValidXMLCharacters(String in) {
    StringBuffer out = new StringBuffer(); // Used to hold the output.
    char current; // Used to reference the current character.

    if (in == null || ("".equals(in)))
        return ""; // vacancy test.
    for (int i = 0; i < in.length(); i++) {
        current = in.charAt(i); // NOTE: No IndexOutOfBoundsException caught here; it should not happen.
        if ((current == 0x9) || (current == 0xA) || (current == 0xD)
                || ((current >= 0x20) && (current <= 0xD7FF)) || ((current >= 0xE000) && (current <= 0xFFFD))
                || ((current >= 0x10000) && (current <= 0x10FFFF))) {

            out.append(current);/*w  w  w  .  j  a v a  2  s.  c o  m*/
        } else {
            Log.e("Falmarri", "Not a valid character " + new Character(current));
        }
    }
    return out.toString();
}