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 File getCacheDirectory(Context context, boolean preferExternal, String dirName) {
    File appCacheDir = null;/*  w  w w . java 2 s. c  o  m*/
    if (preferExternal && MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            && hasExternalStoragePermission(context)) {
        appCacheDir = getExternalCacheDir(context, dirName);
        Log.e("appCacheDir", appCacheDir.toString());
    }
    if (appCacheDir == null) {
        appCacheDir = context.getCacheDir();
    }
    if (appCacheDir == null) {
        String cacheDirPath = "/data/data/" + context.getPackageName() + "/cache/";
        //Log.w("Can't define system cache directory! '%s' will be used.",cacheDirPath);
        appCacheDir = new File(cacheDirPath);
    }
    return appCacheDir;
}

From source file:Main.java

public static DisplayMetrics getScreenSize(Context context) {
    if (displayMetrics == null) {
        try {//w  w  w. ja v a 2 s.  c  o m

            displayMetrics = new DisplayMetrics();
            displayMetrics.widthPixels = 1280;
            displayMetrics.heightPixels = 720;
            WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
            wm.getDefaultDisplay().getMetrics(displayMetrics);
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());
        }

    }
    return displayMetrics;
}

From source file:Main.java

public static String saveImageToTemporaryDirectory(Bitmap image) {
    Log.d(TAG, "[AirImagePickerUtils] Entering saveImageToTemporaryDirectory");
    String path = "";
    FileOutputStream outputStream;
    try {/*from   w  ww.  j  a  v  a2  s . c  o m*/
        File file = getTemporaryFile(".jpg");
        outputStream = new FileOutputStream(file);
        outputStream.write(getJPEGRepresentationFromBitmap(image));
        outputStream.close();
        path = file.getAbsolutePath();
        Log.d(TAG, "[AirImagePickerUtils] saveImageToTemporaryDirectory path:" + path);
    } catch (IOException e) {
        Log.e(TAG, "[AirImagePickerUtils] saveImageToTemporaryDirectory error:" + e.toString());
        // Error while creating file
    }
    Log.d(TAG, "[AirImagePickerUtils] Exiting saveImageToTemporaryDirectory");
    return path;
}

From source file:Main.java

public static void checkGLError(String msg) {
    int error = GLES20.glGetError();
    if (error != GLES20.GL_NO_ERROR) {
        String str = msg + ": glError 0x" + Integer.toHexString(error);
        Log.e(TAG, str);
        int values[] = new int[2];
        GLES20.glGetIntegerv(GLES20.GL_ARRAY_BUFFER_BINDING, values, 0);
        GLES20.glGetIntegerv(GLES20.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, values, 1);
        Log.e(TAG, "Current bound array buffer: " + values[0]);
        Log.e(TAG, "Current bound vertex attrib: " + values[1]);
        throw new RuntimeException(msg);
    }/* w w  w  .  j  ava  2s  .c  o  m*/
}

From source file:Main.java

public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {

    Cursor cursor = null;/*www .j  a va  2s. com*/
    final String column = "_data";
    final String[] projection = { column };

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
        if (cursor != null && cursor.moveToFirst()) {
            final int column_index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(column_index);
        }
    } catch (Exception e) {
        Log.e("tmessages", e.getMessage());
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return null;
}

From source file:Main.java

public static void remove(Context context, String name) {
    try {//from w  w  w  . jav a  2  s  .co m
        SharedPreferences.Editor editor = context
                .getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).edit();
        editor.remove(name);
        editor.commit();
    } catch (Exception e) {
        Log.e("datautils", e.getMessage() + "");
    }
}

From source file:Main.java

public static void logScanReport(Context c, String[] logs) {
    String dir = c.getExternalFilesDir(null).getParent();
    try {//from   ww w .java 2 s .c om
        File file = new File(dir + "/last_scan.log");
        boolean append = false;
        // if file doesnt exists, then create it
        if (!file.exists()) {
            file.createNewFile();
        } else {
            /*
            if(file.length() >= 2097152){
               // set log file max size to 2mb
               append = false;
            }
             */
        }
        FileOutputStream fos = new FileOutputStream(file, append);

        for (String log : logs) {
            fos.write((log + "\n\n").getBytes());
        }
        fos.close();
    } catch (IOException ioe) {
        Log.e("AndroidUtils", "An exception has occured in logScanReport!");
        ioe.printStackTrace();
    }
}

From source file:Main.java

public static String getIpAddress() {
    String ipaddress = "";

    try {//  w ww .  j av a2 s .  c om
        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en
                .hasMoreElements();) {
            NetworkInterface intf = en.nextElement();
            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
                InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress()) {
                    ipaddress = ipaddress + ";" + inetAddress.getHostAddress().toString();
                }
            }
        }
    } catch (SocketException ex) {
        ipaddress = null;
        Log.e("WifiPreference IpAddress", ex.toString());
    }
    return ipaddress;
}

From source file:Main.java

public static void showShortToast(final Context context, int stringResId) {
    try {//from   www.ja  v a 2  s .  c o m
        showShortToast(context, context.getResources().getString(stringResId));
    } catch (Exception e) {
        Log.e(TAG, "showShortToast  context.getResources().getString(resId) >>  catch (Exception e) {"
                + e.getMessage());
    }
}

From source file:Main.java

public static boolean unzipFile(InputStream fis, String destDir) {
    final byte[] buffer = new byte[4096];
    ZipInputStream zis = null;//from  ww  w.j  a  v  a2 s.  com
    Log.e("Unzip", "destDir = " + destDir);
    try {
        // make sure the directory is existent
        File dstFile = new File(destDir);
        if (!dstFile.exists()) {
            dstFile.mkdirs();
        } else {
            int fileLenght = dstFile.listFiles().length;
            if (fileLenght >= 2) {
                return true;
            }
        }
        zis = new ZipInputStream(fis);
        ZipEntry entry;

        while ((entry = zis.getNextEntry()) != null) {
            String fileName = entry.getName();

            if (entry.isDirectory()) {
                new File(destDir, fileName).mkdirs();

            } else {
                BufferedOutputStream bos = new BufferedOutputStream(
                        new FileOutputStream(new File(destDir, fileName)));
                int lenRead;

                while ((lenRead = zis.read(buffer)) != -1) {
                    bos.write(buffer, 0, lenRead);
                }

                bos.close();
            }

            zis.closeEntry();
        }

        return true;

    } catch (IOException e) {
        e.printStackTrace();

    } finally {
        if (zis != null) {
            try {
                zis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return false;
}