List of usage examples for android.util Log d
public static int d(String tag, String msg)
From source file:Main.java
public static String calculateAge(Context context, String date) { final String FACEBOOK = "MM/dd/yyyy"; try {//www. j a va2 s. c o m SimpleDateFormat sf = new SimpleDateFormat(FACEBOOK, Locale.ENGLISH); sf.setLenient(true); Date birthDate = sf.parse(date); Date now = new Date(); int age = now.getYear() - birthDate.getYear(); birthDate.setHours(0); birthDate.setMinutes(0); birthDate.setSeconds(0); birthDate.setYear(now.getYear()); if (birthDate.after(now)) { age -= 1; } return Integer.toString(age); } catch (Exception e) { Log.d("DEBUG", "exception in getTwitterDate:"); e.printStackTrace(); return "Unknown"; } }
From source file:Main.java
public static void LOGD(final String tag, String message) { //noinspection PointlessBooleanExpression,ConstantConditions if (debug || Log.isLoggable(tag, Log.DEBUG)) { Log.d(tag, message); }/*from w w w .j a va 2s . co m*/ }
From source file:Main.java
private static Method getColumnSetMethod(Class<?> entityType, Field field, Class<?> typeClass, String suffix) { String fieldName = field.getName(); Method setMethod = null;/*from w ww . ja v a 2 s . c om*/ if (field.getType() == boolean.class) { setMethod = getBooleanColumnSetMethod(entityType, field, typeClass, suffix); } if (setMethod == null) { String methodName = "set" + fieldName.substring(0, 1).toUpperCase(Locale.getDefault()) + fieldName.substring(1) + suffix; try { setMethod = entityType.getDeclaredMethod(methodName, typeClass); } catch (NoSuchMethodException e) { Log.d("T", methodName + " not exist"); } } return setMethod; }
From source file:Main.java
public static String getDaysBetween(String date1, String date2) { // input is expected to be exactly like; 2011-01-05 // date2 must be before date1 String result = ""; try {/* w w w. ja v a 2s . c om*/ Date dateOne = DateUtils.parseDate(date1, new String[] { "yyyy-MM-dd" }); Calendar cal1 = Calendar.getInstance(); cal1.setTime(dateOne); Date dateTwo = DateUtils.parseDate(date2, new String[] { "yyyy-MM-dd" }); Calendar cal2 = Calendar.getInstance(); cal2.setTime(dateTwo); long diff = dateOne.getTime() - dateTwo.getTime(); Log.d(TAG, "days in between:" + (TimeUnit.MILLISECONDS.toSeconds(diff) / 60 / 60 / 24)); } catch (Exception ex) { Log.w(TAG, ex.toString()); } return result; }
From source file:Main.java
public static void d(String tag, String message) { if (D) Log.d(tag, message); }
From source file:Main.java
public static void slowDebug(String TAG, String text, int sleep) { for (String s : text.split("\n")) { Log.d(TAG, s); try {/*from w w w . j a v a2s. co m*/ Thread.sleep(sleep); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:Main.java
/** * Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory * is persistent and available to other applications like gallery. * * @param type Media type. Can be video or image. * @return A file object pointing to the newly created file. *//*from w w w .j a v a 2s .c om*/ public static File getOutputMediaFile(File myDir) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. Log.i("CameraSample", "about to check state of external storage"); if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { Log.d("CameraSample", "externalstoragestate was " + Environment.getExternalStorageState()); return null; } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile = new File(myDir + File.separator + "VID_" + timeStamp + ".mp4"); return mediaFile; }
From source file:Main.java
public static void insertPlaceholderCall(ContentResolver contentResolver, String name, String number) { ContentValues values = new ContentValues(); values.put(CallLog.Calls.NUMBER, number); values.put(CallLog.Calls.DATE, System.currentTimeMillis()); values.put(CallLog.Calls.DURATION, 0); values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE); values.put(CallLog.Calls.NEW, 1);// w ww .ja v a 2 s.c o m values.put(CallLog.Calls.CACHED_NAME, name); values.put(CallLog.Calls.CACHED_NUMBER_TYPE, 0); values.put(CallLog.Calls.CACHED_NUMBER_LABEL, ""); Log.d("Call Log", "Inserting call log placeholder for " + number); contentResolver.insert(CallLog.Calls.CONTENT_URI, values); }
From source file:Main.java
private static Method getBooleanColumnSetMethod(Class<?> entityType, Field field, Class<?> typeClass, String suffix) {/*from w w w.java2s . co m*/ String fieldName = field.getName(); String methodName = null; if (isStartWithIs(field.getName())) { methodName = "set" + fieldName.substring(2, 3).toUpperCase(Locale.getDefault()) + fieldName.substring(3) + suffix; } else { methodName = "set" + fieldName.substring(0, 1).toUpperCase(Locale.getDefault()) + fieldName.substring(1) + suffix; } try { return entityType.getDeclaredMethod(methodName, typeClass); } catch (NoSuchMethodException e) { Log.d("L", methodName + " not exist"); } return null; }
From source file:Main.java
public static String keyHash(Context context) { String key = ""; try {//from ww w. j a v a 2 s. c om PackageInfo info = context.getPackageManager().getPackageInfo("org.tathva.triloaded.anubhava", PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); key = Base64.encodeToString(md.digest(), Base64.DEFAULT); Log.d("anas", key); } } catch (NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } return key; }