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 isExternalStorageAvailable() {
    String state = Environment.getExternalStorageState();
    if (!Environment.MEDIA_MOUNTED.equals(state)) {
        Log.d(TAG, "The external storage is not available.");
        return false;
    }//  w  ww.  ja v a 2  s .  com
    return true;
}

From source file:Main.java

/** Create a File for saving an image or video */
public static File getOutputMediaFile() {
    // To be safe, you should check that the SDCard is mounted
    // using Environment.getExternalStorageState() before doing this.

    File mediaStorageDir = new File(
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), APPDIR);
    // This location works best if you want the created images to be shared
    // between applications and persist after your app has been uninstalled.

    // Create the storage directory if it does not exist

    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d(APPDIR, "failed to create directory");
            return null;
        }//from w w w  .  j  av a  2 s .  c  om
    }

    // Create a media file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File mediaFile;
    mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
    return mediaFile;
}

From source file:Main.java

private static void logInConsole(ArrayList<Integer> timePoints) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < timePoints.size(); i++) {
        sb.append(timePoints.get(i)).append(" ");
    }/*from  ww w . j av  a  2s .  c o  m*/
    Log.d(TAG, sb.toString());
}

From source file:Main.java

public static void startDataCheck(Activity callingActivity) {
    Log.d(TAG, "launching speech check");
    Intent checkIntent = new Intent();
    checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    callingActivity.startActivityForResult(checkIntent, SPEECH_DATA_CHECK_CODE);
}

From source file:Main.java

private static DateTime getDateFromISO(String ISOString) {
    //DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
    DateTimeFormatter parser = ISODateTimeFormat.dateTimeNoMillis().withZoneUTC();
    try {//ww  w .ja  v  a2 s.c om
        return parser.parseDateTime(ISOString);
    } catch (Throwable e) {
        try {
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US);
            df.setTimeZone(TimeZone.getTimeZone("UTC"));
            return new DateTime(df.parse(ISOString));
        } catch (Throwable ignored) {
            Log.d("ERROR", "Failed parsing string into date");
            e.printStackTrace();
        }
    }
    return null;
}

From source file:Main.java

public static int convertMonthToDigit(String month) {
    month = month.toUpperCase();//from ww  w  . j a va 2  s  .  c  om

    if (month.equals("JAN")) {
        return 0;
    }

    else if (month.equals("FEB")) {
        return 1;
    } else if (month.equals("MAR")) {
        return 2;
    } else if (month.equals("APR")) {
        return 3;
    } else if (month.equals("MAY")) {
        return 4;
    } else if (month.equals("JUN")) {
        return 5;
    } else if (month.equals("JUL")) {
        return 6;
    } else if (month.equals("AUG")) {
        return 7;
    } else if (month.equals("SEP")) {
        return 8;
    } else if (month.equals("OCT")) {
        return 9;
    } else if (month.equals("NOV")) {
        return 10;
    } else if (month.equals("DEC")) {
        return 11;
    } else {
        Log.d("ConvertUtil", "convertMonthToDigit = wasnt passed proper stuff");
        return 0;
    }
}

From source file:Main.java

public static byte[] copyFile(InputStream is, FileOutputStream os) throws IOException {
    MessageDigest digester = null;
    try {/* w  ww .  jav a2  s.c om*/
        digester = MessageDigest.getInstance("MD5");

        byte[] buffer = new byte[16 * 1024];
        int length;
        while ((length = is.read(buffer)) > 0) {
            os.write(buffer, 0, length);
            digester.update(buffer, 0, length);
        }
        os.flush();
        os.close();

        //os.getFD().sync();
        //Log.d(TAG, "done copying");
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        is.close();
        Log.d(TAG, "done copying");
    }
    if (digester != null) {
        byte[] digest = digester.digest();
        return digest;
    }

    return null;
}

From source file:Main.java

/**
 * Print hash key/*w w w . j av a 2s . c o  m*/
 */
public static void printHashKey(Context context) {
    try {
        PackageInfo info = context.getPackageManager().getPackageInfo(TAG, PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String keyHash = Base64.encodeToString(md.digest(), Base64.DEFAULT);
            Log.d(TAG, "keyHash: " + keyHash);
        }
    } catch (NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }
}

From source file:Main.java

public static void dumpParameters(Parameters parameters) {
    String flattened = parameters.flatten();
    StringTokenizer tokenizer = new StringTokenizer(flattened, ";");
    Log.d(TAG, "Dump all camera parameters:");
    while (tokenizer.hasMoreElements()) {
        Log.d(TAG, tokenizer.nextToken());
    }//from  w w w . ja v  a  2s .co m
}

From source file:Main.java

public static void d(String message) {
    Log.d(LOGTAG, message);
    if (writer != null) {
        writer.write(message);//  w ww.jav  a 2s . c  o  m
        writer.write("\n");
    }
}