List of usage examples for android.util Log i
public static int i(String tag, String msg)
From source file:Main.java
public static File getCacheDir(Context context) { Log.i("getCacheDir", "cache sdcard state: " + Environment.getExternalStorageState()); if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { File cacheDir = context.getExternalCacheDir(); if (cacheDir != null && (cacheDir.exists() || cacheDir.mkdirs())) { Log.i("getCacheDir", "cache dir: " + cacheDir.getAbsolutePath()); return cacheDir; }// w ww . j a va2 s.c om } File cacheDir = context.getCacheDir(); Log.i("getCacheDir", "cache dir: " + cacheDir.getAbsolutePath()); return cacheDir; }
From source file:Main.java
public static Bitmap createResizedBitmap(Bitmap srcBit, int newWidth, int newHeight) { int width = srcBit.getWidth(); int height = srcBit.getHeight(); // calculate the scale - in this case = 0.4f float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap resizedBitmap = Bitmap.createBitmap(srcBit, 0, 0, width, height, matrix, true); width = resizedBitmap.getWidth();/*from ww w .j a v a 2 s .c om*/ height = resizedBitmap.getHeight(); Log.i("ImageResize", "Image Resize Result : " + Boolean.toString((newHeight == height) && (newWidth == width))); return resizedBitmap; }
From source file:Main.java
/*** * Extract zipfile to outdir with complete directory structure * @param zipfile Input .zip file/*from w w w . j a v a2 s.co m*/ * @param outdir Output directory */ public static void extract(InputStream zipfile, File outdir) { try { ZipInputStream zin = new ZipInputStream(zipfile); ZipEntry entry; String name, dir; Log.i("OF", "uncompressinggggg "); while ((entry = zin.getNextEntry()) != null) { name = entry.getName(); if (entry.isDirectory()) { mkdirs(outdir, name); continue; } /* this part is necessary because file entry can come before * directory entry where is file located * i.e.: * /foo/foo.txt * /foo/ */ dir = dirpart(name); if (dir != null) mkdirs(outdir, dir); extractFile(zin, outdir, name); } zin.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void i(String tag, String message) { Log.i(tag, message); }
From source file:Main.java
public static void mediaScannerCall(final Context context, final File file) { new AsyncTask<Void, Void, Void>() { @Override//w ww . ja v a 2s .c om protected Void doInBackground(Void... params) { MediaScannerConnection.scanFile(context, new String[] { file.toString() }, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { Log.i("ExternalStorage", "Scanned " + path + ":"); Log.i("ExternalStorage", "-> uri=" + uri); } }); return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null); }
From source file:Main.java
/** * Checks device for network connectivity * * @return If the device has data connectivity *//*from ww w.j ava 2 s .com*/ public static boolean isNetworkAvailable(Context context) { boolean state = false; if (context != null) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnected()) { Log.i(TAG, "The device currently has data connectivity"); state = true; } else { Log.i(TAG, "The device does not currently have data connectivity"); state = false; } } return state; }
From source file:Main.java
/** * A reusable method to make our simple XOR hiding method. Since the interesting part is * how we get the hiding key, we've moved everything else into this reusable method. * * @param msg The message to hide/unhide * @param pwd Our password key to use in the XOR process * @param isHidden whether we're encrypting or unencrypting (relevant only for logging) *//*from ww w .j a v a2 s . com*/ public static void doHiding(byte[] msg, byte[] pwd, boolean isHidden) { xorValues(msg, pwd); if (!isHidden) { String hiddenMessage = Base64.encodeToString(msg, 0); Log.i(TAG, String.format("Hidden Message: %s", hiddenMessage)); doHiding(msg, pwd, true); } else { Log.i(TAG, String.format("Unhidden Message: %s", new String(msg))); } }
From source file:Main.java
public static void jlog(String s) { Log.i(TAG, s); }
From source file:Main.java
public static String readInStream(InputStream inStream) { try {/*from w w w . ja v a 2s . com*/ ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[512]; int length = -1; while ((length = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, length); } outStream.close(); inStream.close(); return outStream.toString(); } catch (IOException e) { Log.i("FileTest", e.getMessage()); } return null; }
From source file:Main.java
public static void sendSMS(String phoneNo, String message) { Log.i("Sending SMS to " + phoneNo, ""); try {/*from w w w .ja v a 2 s . c o m*/ SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo, null, message, null, null); } catch (Exception e) { e.printStackTrace(); } }