List of usage examples for android.util Log d
public static int d(String tag, String msg)
From source file:Main.java
/** Create a File for saving an image or video */ public static File getOutputMediaFile(int type) { if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) return null; File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "MacauFood"); // 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("MacauFood", "failed to create directory"); return null; }//from ww w .j a v a2s . c o m } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE) { mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); } else if (type == MEDIA_TYPE_VIDEO) { mediaFile = new File(mediaStorageDir.getPath() + File.separator + "VID_" + timeStamp + ".mp4"); } else { return null; } return mediaFile; }
From source file:Main.java
/** * Prints your current certificate signature to the Logcat. Use this method to obtain your certificate signature. * * @param context The application context. *//*ww w . java 2 s . c om*/ public static void getCertificateSignature(Context context) { try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES); // The APK is signed with multiple signatures, probably it was tampered. if (packageInfo.signatures.length > 1) { return; } for (Signature signature : packageInfo.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.d("TAMPERING_PROTECTION", "**" + Base64.encodeToString(md.digest(), Base64.DEFAULT) + "**"); } } catch (Exception exception) { Log.d("TAMPERING_PROTECTION", exception.getStackTrace().toString()); } }
From source file:Main.java
private static File getAlbumDir() { File storageDir = null;/* w ww . j av a 2 s . c om*/ if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Telepathy"); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { Log.d("android_utilities", "failed to create directory"); return null; } } } else { Log.d("android_utilities", "External storage is not mounted READ/WRITE."); } return storageDir; }
From source file:Main.java
public static String GET(String url) { InputStream inputStream = null; String result = ""; try {/* ww w . j a v a2 s . co m*/ // create HttpClient HttpClient httpclient = new DefaultHttpClient(); // make GET request to the given URL HttpResponse httpResponse = httpclient.execute(new HttpGet(url)); // receive response as inputStream inputStream = httpResponse.getEntity().getContent(); // convert inputstream to string if (inputStream != null) result = convertInputStreamToString(inputStream); else result = "Did not work!"; } catch (Exception e) { Log.d("InputStream", e.getLocalizedMessage()); } return result; }
From source file:Main.java
private static void setStartOfMonthToCalendar(Calendar c) { c.set(Calendar.DAY_OF_MONTH, c.getMinimum(Calendar.DAY_OF_MONTH)); setStartOfDayToCalendar(c);//from w w w .ja va 2 s . c o m Log.d("La Cuenta: ", "Min of Current Month: " + DateFormat.getInstance().format(c.getTime())); }
From source file:com.google.android.apps.santatracker.util.SantaLog.java
public static void d(String tag, String msg) { if (LOG_ENABLED) { Log.d(tag, msg); } }
From source file:Main.java
/** * Vibrate if we can / are allowed to./*from w w w. j av a2 s . c o m*/ */ public static void vibrate(@Nullable Vibrator vibrator, int milliseconds) { if (vibrator == null) { Log.i(TAG, "Not vibrating; no vibration support / vibrator not set up"); return; } try { vibrator.vibrate(milliseconds); Log.d(TAG, milliseconds + "ms vibration started..."); } catch (SecurityException e) { Log.i(TAG, "Not vibrating: " + e.getMessage()); } }
From source file:Main.java
public static void fastFileCopy(File source, File target) { FileChannel in = null;//from w w w.j a v a2 s .com FileChannel out = null; long start = System.currentTimeMillis(); FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(source); in = fis.getChannel(); fos = new FileOutputStream(target); out = fos.getChannel(); long size = in.size(); long transferred = in.transferTo(0, size, out); while (transferred != size) { transferred += in.transferTo(transferred, size - transferred, out); } } catch (IOException e) { e.printStackTrace(); } finally { close(fis); close(fos); close(in); close(out); } long end = System.currentTimeMillis(); Log.d(target.getAbsolutePath(), nf.format(source.length()) + "B: " + ((end - start > 0) ? nf.format(source.length() / (end - start)) : 0) + " KB/s"); }
From source file:circleplus.app.utils.JSONUtils.java
@SuppressWarnings("unchecked") public static BaseType consume(Parser<? extends BaseType> parser, String content) throws Exception { if (D)/* w w w . ja v a2 s . c om*/ Log.d(TAG, "http response: " + content); try { JSONObject json = new JSONObject(content); Iterator<String> it = (Iterator<String>) json.keys(); if (it.hasNext()) { String key = it.next(); // we had checked network error on http level // so the parser here must be instance of StatusParser if ("error".equals(key)) { return parser.parse(json.getJSONObject(key)); } else { Object obj = json.get(key); if (obj instanceof JSONArray) { return parser.parse((JSONArray) obj); } else { return parser.parse((JSONObject) obj); } } } else { throw new Exception("Error parsing JSON response, " + "object has no single child key."); } } catch (JSONException ex) { throw new Exception("Error parsing JSON response: " + ex.getMessage()); } }
From source file:io.goodway.navitia_android.Request.java
public static void getWays(Action a, ArrayList<Pair> pairs, Address from, Address to, ErrorAction error) { try {//www . jav a 2s.co m new GetWays(a, pairs, from, to, error).execute(); Log.d("getWays", "getWays"); } catch (IllegalStateException e) { Log.e(e.getMessage(), "exception"); } }