Example usage for android.util Log d

List of usage examples for android.util Log d

Introduction

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

Prototype

public static int d(String tag, String msg) 

Source Link

Document

Send a #DEBUG log message.

Usage

From source file:Main.java

public static boolean executeAsRoot(String command) {
    try {// w w w . j a  va2  s.  c o m

        Process suProcess = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());

        os.writeBytes(command + "\n");
        os.flush();
        Log.d("ROOT", command);

        os.writeBytes("exit\n");
        os.flush();

        try {
            int suProcessRet = suProcess.waitFor();
            if (255 != suProcessRet)
                return true;
            else
                return false;
        } catch (Exception ex) {
            Log.w("ROOT-ERROR", ex);
        }
    } catch (IOException ex) {
        Log.w("ROOT", "Can't get root access", ex);
    } catch (SecurityException ex) {
        Log.w("ROOT", "Can't get root access", ex);
    } catch (Exception ex) {
        Log.w("ROOT", "Error executing internal operation", ex);
    }
    return false;
}

From source file:Main.java

public static void d(String msg) {
    if (DEBUG) {/*w  w  w .  j av  a 2s  .  c  om*/
        Log.d(_FILE_(), "[" + getLineMethod() + "]" + msg);
    }
}

From source file:Main.java

public static void saveToFile(String filename, Bitmap bmp) {
    try {/*from www. j  ava  2 s .c o  m*/
        FileOutputStream out = new FileOutputStream(filename);
        bmp.compress(CompressFormat.PNG, 100, out);
        out.flush();
        out.close();
    } catch (Exception e) {
        Log.d("Exception", e.getMessage());
    }
}

From source file:Main.java

private static void injectClassField(Class clazz, String fieldStr, long newValue) {
    try {/*from  w  ww .j  ava 2 s  .  c o m*/
        final Field field = clazz.getDeclaredField(fieldStr);
        if (field != null) {
            field.setAccessible(true);
            Object obj = null;
            field.set(obj, newValue);
        }
    } catch (Exception e) {
        Log.d("REFLECTION", clazz.getSimpleName() + " injection failed for field: " + fieldStr);
    }
}

From source file:Main.java

public static String saveImageToTemporaryDirectory(Bitmap image) {
    Log.d(TAG, "[AirImagePickerUtils] Entering saveImageToTemporaryDirectory");
    String path = "";
    FileOutputStream outputStream;
    try {// ww  w  .  j  av  a 2 s  .co  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 writeToZipFileAsDateTime(File source) throws IOException {
    String dateTime = new Date(System.currentTimeMillis()).toString().replaceAll("[:/]", ".");
    String sourceAbsolute = source.getAbsolutePath();
    Log.d("sourceAbsolute: ", sourceAbsolute);
    String fullName = (sourceAbsolute + "-" + dateTime + ".zip");
    compressAFileToZip(new File(fullName), source);
}

From source file:Main.java

public static void putImageInCache(File file, Bitmap bmp) {
    try {//from ww  w.  ja v  a 2 s .c o m
        file.createNewFile();
        FileOutputStream out = new FileOutputStream(file);
        bmp.compress(Bitmap.CompressFormat.PNG, 80, out);
        Log.d("CACHE", "FILE : " + out.toString());
        out.flush();
        out.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void dumpBundleKeys(Bundle bundle) {
    if (bundle == null) {
        Log.d(TAG, "extras bundle is null");
        return;//from   w w  w  .ja  v a2 s .  c o  m
    }
    Log.d(TAG, "bundle keys:");
    for (String o : bundle.keySet()) {
        Log.d(TAG, o);
    }
}

From source file:Main.java

public static void saveRgb2Bitmap(IntBuffer buf, String filePath, int width, int height) {
    final int[] pixelMirroredArray = new int[width * height];
    Log.d("TryOpenGL", "Creating " + filePath);
    BufferedOutputStream bos = null;
    try {// www.jav  a 2  s.co m
        int[] pixelArray = buf.array();
        // rotate 180 deg with x axis because y is reversed
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                pixelMirroredArray[(height - i - 1) * width + j] = pixelArray[i * width + j];
            }
        }
        bos = new BufferedOutputStream(new FileOutputStream(filePath));
        Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        bmp.copyPixelsFromBuffer(IntBuffer.wrap(pixelMirroredArray));
        bmp.compress(Bitmap.CompressFormat.JPEG, 90, bos);
        bmp.recycle();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (bos != null) {
            try {
                bos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:Main.java

public static final void log(String message) {
    StackTraceElement ste = Thread.currentThread().getStackTrace()[3];
    String className = ste.getClassName();
    className = className.substring(className.lastIndexOf(".") + 1);
    String methodName = ste.getMethodName();
    int lineNum = ste.getLineNumber();
    String logText = String.format("%s(%s):%s", methodName, lineNum, message);
    Log.d(className, logText);
}