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

/**
 * A safe way to get an instance of the Camera object.
 *//*from  w w  w . ja va 2s  .c  om*/
public static Camera getCameraInstance(Context context, int CameraId) {
    Camera c = null;
    if (!checkCameraHardware(context)) {
        return c; // device has no camera
    }

    try {
        c = Camera.open(CameraId); // attempt to get a Camera instance
        Log.d(TAG, "open camera succeed");
    } catch (Exception e) {
        // Camera is not available (in use or does not exist)
        Log.d(TAG, "open camera failed");
    }
    return c; // returns null if camera is unavailable
}

From source file:Main.java

public static String formatVersion(Context context, int i) {
    int j = 0xff & i >> 8;
    String s;//from   w ww  . j  a  v  a  2 s.  c  o  m
    int k;
    if (j == 0)
        s = (new StringBuilder()).append(0xf & i >> 24).append(".").append(0xff & i >> 16).toString();
    else
        s = (new StringBuilder()).append(0xf & i >> 24).append(".").append(0xff & i >> 16).append(".").append(j)
                .toString();
    Log.d("MicroMsg.SDK.ChannelUtil", (new StringBuilder("minminor ")).append(j).toString());
    k = 0xfffffff & i;
    if (context != null)
        try {
            PackageInfo packageinfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 128);
            if (packageinfo != null) {
                k = packageinfo.versionCode;
                s = packageinfo.versionName;
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    if (fullVersionInfo) {
        s = (new StringBuilder()).append(s).append(" r").append(k).append("(build.").append(buildRev)
                .append(")").toString();
        Log.d("MicroMsg.SDK.ChannelUtil", (new StringBuilder("full version: ")).append(s).toString());
    }
    return s;
}

From source file:Main.java

public static String findBuildPropValueOf(String prop) {
    String mBuildPath = "/system/build.prop";
    String DISABLE = "disable";
    String value = null;// ww  w.j av a2s . com
    try {
        //create properties construct and load build.prop
        Properties mProps = new Properties();
        mProps.load(new FileInputStream(mBuildPath));
        //get the property
        value = mProps.getProperty(prop, DISABLE);
        Log.d(TAG, String.format("Helpers:findBuildPropValueOf found {%s} with the value (%s)", prop, value));
    } catch (IOException ioe) {
        Log.d(TAG, "failed to load input stream");
    } catch (NullPointerException npe) {
        //swallowed thrown by ill formatted requests
    }

    if (value != null) {
        return value;
    } else {
        return DISABLE;
    }
}

From source file:Main.java

public static String[] getMounts(CharSequence path) {
    BufferedReader bufferedReader = null;
    try {//w  w  w  .j  a  va2  s .com
        bufferedReader = new BufferedReader(new FileReader("/proc/mounts"), 256);
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            if (line.contains(path)) {
                return line.split(" ");
            }
        }
    } catch (FileNotFoundException ignored) {
        Log.d("TAG", "/proc/mounts does not exist");
    } catch (IOException ignored) {
        Log.d("TAG", "Error reading /proc/mounts");
    } finally {
        if (bufferedReader != null) {
            try {
                bufferedReader.close();
            } catch (IOException ignored) {
                // ignored
            }
        }
    }
    return null;
}

From source file:Main.java

/**
 * create a new filename based on the current time
 * @return//from w  ww.ja  v a2 s .c o  m
 */
@SuppressLint("SimpleDateFormat")
public static String createFileName() {
    File pictureFileDir = getAppDir();

    // display and log an error when a directory cant be found or created
    if (!pictureFileDir.exists() && !pictureFileDir.mkdirs()) {
        Log.d(TAG, "Can't create directory to save image.");
        return "";
    }

    // create a name for the picture based on the current date
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US);
    String date = dateFormat.format(new Date());
    String photoFile = "Picture_" + date + ".jpg";

    String fileName = pictureFileDir.getPath() + File.separator + photoFile;

    return fileName;
}

From source file:Main.java

public static void createFonts(Context context, String path) {
    fonts = new HashMap<>();
    try {//from  w  ww  .j  ava  2s  .c o  m
        String[] listOfFonts = listAssetFiles(path, context);
        for (String s : listOfFonts) {
            Typeface typeface = Typeface.createFromAsset(context.getAssets(), path + "/" + s);
            fonts.put(s.substring(0, s.lastIndexOf(".")), typeface);
            Log.d("PKFontUtils", "fonts" + s.substring(0, s.lastIndexOf(".")));
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

private static Boolean currentGreaterThenOld(String currentDate, String oldDate) {
    if (currentDate.isEmpty() || oldDate.isEmpty())
        return false;

    try {/* www  . j a  v a2 s .c  om*/
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
        Date current = formatter.parse(currentDate);
        Date old = formatter.parse(oldDate);

        if (old.compareTo(current) < 0) {
            Log.d(TAG, "compareDate current Date : " + current.toString() + " is greater then Old Date : "
                    + old.toString());
            return true;
        }

    } catch (ParseException e1) {
        e1.printStackTrace();
    }
    return false;
}

From source file:Main.java

public static void LOG_D(Class<?> paramClass, String paramString) {
    if (DEBUG) {//from www  .  j  av a  2s. c  o  m
        String str = paramClass.getName();
        if (str != null) {
            str = str.substring(1 + str.lastIndexOf("."));
        }
        int i = paramString.length();
        if (i > LOG_SIZE_LIMIT) {
            int j = 0;
            int k = 1 + i / LOG_SIZE_LIMIT;
            while (j < k + -1) {
                Log.d(LOG_TAG, paramString.substring(j * LOG_SIZE_LIMIT, LOG_SIZE_LIMIT * (j + 1)));
                j++;
            }
            Log.d(LOG_TAG, paramString.substring(j * LOG_SIZE_LIMIT, i));
        } else {
            Log.d(LOG_TAG, str + " -> " + paramString);
        }
    }

}

From source file:Main.java

public static String[] getMounts(final String path) {
    try {/*from  w  w w .j ava  2s .co m*/
        BufferedReader br = new BufferedReader(new FileReader("/proc/mounts"), 256);
        String line = null;
        while ((line = br.readLine()) != null) {
            if (line.contains(path)) {
                return line.split(" ");
            }
        }
        br.close();
    } catch (FileNotFoundException e) {
        Log.d(TAG, "/proc/mounts does not exist");
    } catch (IOException e) {
        Log.d(TAG, "Error reading /proc/mounts");
    }
    return null;
}

From source file:Main.java

public static int[] readBin83PtIndex(String dir, String fileName) {
    int i = 0;/*from   www.j av a  2  s  . c  o  m*/
    int x = 0;
    int[] tab = new int[83];
    File sdLien = Environment.getExternalStorageDirectory();
    File inFile = new File(sdLien + File.separator + dir + File.separator + fileName);
    Log.d(TAG, "path of file : " + inFile);
    if (!inFile.exists()) {
        throw new RuntimeException("File doesn't exist");
    }
    DataInputStream in = null;
    try {
        in = new DataInputStream(new FileInputStream(inFile));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    try {
        x = in.readInt();
        while (true) {
            tab[i] = x;
            i++;
            x = in.readInt();
        }
    } catch (EOFException e) {
        try {
            Log.d(TAG, "close");
            in.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (in != null) {
            try { //free ressources
                Log.d(TAG, "close");
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return tab;
}