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 void cancel(Context context, Intent intent) {
    PendingIntent p = PendingIntent.getBroadcast(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    alarm.cancel(p);/*w  ww  .  java 2 s  .c o  m*/
    Log.d("petsitter-alarm", "Alarme cancelado.");
}

From source file:Main.java

public static boolean nonEmpty(EditText editText) {
    if (editText != null && !(TextUtils.isEmpty(editText.getText().toString().trim()))) {
        return YES;
    } else {/* w ww  . jav  a 2 s.  c  om*/
        Log.d("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}

From source file:Main.java

@SuppressWarnings("resource")
public static void writeInfoTophone(Context context, InputStream scriptData, String filePath)
        throws IOException {
    String temp = null;//  ww w. jav a2s  .co m
    Log.d("Tag", "Starting write file");
    FileOutputStream fos = null;
    if (isSdcardAvailable()) {
        removeExistFile(filePath);
        fos = new FileOutputStream(filePath, true);
    } else {
        removeExistFile(filePath);
        fos = context.openFileOutput(filePath, Context.MODE_APPEND);
    }
    BufferedReader mBufferedReader = new BufferedReader(new InputStreamReader(scriptData));
    while ((temp = mBufferedReader.readLine()) != null) {
        fos.write((temp + "\n").getBytes());
    }
    fos.close();
}

From source file:Main.java

/**
 * Print the content of the cursor/*from w w  w .  j a v  a  2 s . c om*/
 *
 * @param cursor, The cursor, which content needs to be printed
 * @param logTag, The log tag
 */
public static void printCursorContent(Cursor cursor, String logTag) {
    if (cursor == null) {
        Log.d(logTag, "Cursor is NULL!");
        return;
    }
    final int columnSpace = 2;
    ArrayList<Integer> columnWidth = new ArrayList<Integer>();
    for (int columnIndex = 0; columnIndex < cursor.getColumnCount(); columnIndex++) {
        String value = cursor.getColumnName(columnIndex);
        int maxWidth = value.length();
        if (cursor.moveToFirst()) {
            do {
                try {
                    value = cursor.getString(columnIndex);
                } catch (Exception e) {
                    value = "BLOB";
                    Log.d(logTag, "Get value from " + cursor.getColumnName(columnIndex) + " failed. Caused by "
                            + e.getLocalizedMessage());
                }
                if (!TextUtils.isEmpty(value) && value.length() > maxWidth) {
                    maxWidth = value.length();
                }
            } while (cursor.moveToNext());
        }
        columnWidth.add(maxWidth + columnSpace);
    }
    ArrayList<ArrayList<String>> tableContent = new ArrayList<ArrayList<String>>();
    for (int columnIndex = 0; columnIndex < cursor.getColumnCount(); columnIndex++) {
        ArrayList<String> columnContent = new ArrayList<String>();
        String value = cursor.getColumnName(columnIndex);
        columnContent.add(appendColumnSpaces(value, columnWidth.get(columnIndex)));
        if (cursor.moveToFirst()) {
            do {
                try {
                    value = cursor.getString(columnIndex);
                } catch (Exception e) {
                    value = "BLOB";
                }
                columnContent.add(appendColumnSpaces(value, columnWidth.get(columnIndex)));
            } while (cursor.moveToNext());
        }
        tableContent.add(columnContent);
    }
    // Including the header
    int maxRowIndex = cursor.getCount() + 1;
    for (int rowIndex = 0; rowIndex < maxRowIndex; rowIndex++) {
        StringBuilder rowValues = new StringBuilder();
        for (int columnIndex = 0; columnIndex < cursor.getColumnCount(); columnIndex++) {
            ArrayList<String> columnValues = tableContent.get(columnIndex);
            rowValues.append(columnValues.get(rowIndex));
        }
        Log.d(logTag, rowValues.toString());
    }
    // set the cursor back the first item
    cursor.moveToFirst();
}

From source file:Main.java

public static MediaMetadataRetriever initMetadataRetriever(String URI) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    if (!URI.contains("http:") && URI.endsWith("mp3")) {
        try {/* w ww  .  j  a v a2  s  . c  o m*/
            retriever.setDataSource(URI);
        } catch (Exception e) {
            Log.d(LOG_TAG, "Failed: " + URI + " " + e.toString());
            e.printStackTrace();
            return null;
        }
    } else {
        return null;
    }
    return retriever;
}

From source file:Main.java

public static String getRealPathFromURI(Context context, Uri contentURI) {
    String TAG = "PINGUINO-getRealPathFromURI";
    String result;/*from w  w w  . j  ava 2  s.co m*/
    Cursor cursor = context.getContentResolver().query(contentURI, null, null, null, null);
    if (cursor == null) {
        result = contentURI.getPath();
    } else {
        Log.d(TAG, "cursor1:" + cursor);
        cursor.moveToFirst();
        Log.d(TAG, "cursor2:" + cursor);
        int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
        Log.d(TAG, "idx:" + idx);
        result = cursor.getString(idx);
        Log.d(TAG, "result:" + result);
        cursor.close();
    }
    return result;
}

From source file:Main.java

public static File getDiskCacheDir(Context context, String fileName) {
    String cachePath;//from w  w w  . j a v  a  2 s.co m
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
            && !Environment.isExternalStorageRemovable()) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }
    Log.d("bonus", "cachePath = " + cachePath);
    return new File(cachePath + File.separator + fileName);
}

From source file:Main.java

public static boolean isAppInstall(Context context, String pkg) {
    if (context == null || pkg == null) {
        return false;
    }/*from  w  ww.ja v  a  2s.c o m*/
    try {
        PackageInfo info = context.getPackageManager().getPackageInfo(pkg, PackageManager.GET_GIDS);
        Log.d(TAG, "app info " + info.packageName);
    } catch (PackageManager.NameNotFoundException e) {
        return false;
    }
    return true;
}

From source file:Main.java

/**
 * debug log/*from   w w w . j a  v a  2s  .c  om*/
 * @param tag tag
 * @param msg log msg
 */
public static void d(String tag, String msg) {
    if (LOG_ENABLE && Log.isLoggable(tag, Log.DEBUG)) {
        Log.d(tag, buildMsg(msg));
    }
}

From source file:Main.java

public static Uri getOutputMediaFileUri() {
    File mediaStorageDir = new File(
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Date");
    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d("Date", "failed to create directory");
            return null;
        }//from ww w. j av a  2 s .  com
    }

    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date());
    File mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");

    return Uri.fromFile(mediaFile);
}