List of usage examples for android.util Log e
public static int e(String tag, String msg, Throwable tr)
From source file:Main.java
public static Cursor getAllCallLogAboutACaller(Context context, String callerNumber) { // cancello la chiamata in uscita se nelle preferenze ? settata tale opzione Uri delUri = Uri.withAppendedPath(CallLog.Calls.CONTENT_URI, ""); Cursor cursor = context.getContentResolver().query(delUri, null, android.provider.CallLog.Calls.NUMBER + "=?", new String[] { "404" }, null); try {/*from w ww .jav a 2 s. c o m*/ boolean moveToFirst = cursor.moveToFirst(); Log.i("MOVETOFIRST", "moveToFirst=" + moveToFirst); do { int numberColumn = cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER); String callerPhoneNumber = cursor.getString(numberColumn); Log.i(TAG, "numero : " + callerPhoneNumber); } while (cursor.moveToNext()); } catch (Exception e) { Log.e(TAG, "Problem moving to first entry", e); } return cursor; }
From source file:Main.java
/** * This method gives you the bitmap of the image you tell it to load from the filesystem. * @param uri The file location.//from w w w . j a va 2 s .c o m * @return The bitmap of the photo at the location you specify. */ public static Bitmap getImageBitmap(String uri) { final File f = new File(uri); try { return getImage(f.getCanonicalPath()); } catch (IOException e) { Log.e(TAG, "Error loading image for loading", e); return null; } }
From source file:Main.java
public static boolean fileWriteOneLine(String fname, String value, Process su) { try {/* ww w . jav a2s . c o m*/ DataOutputStream out = new DataOutputStream(su.getOutputStream()); out.writeBytes("echo " + value + " > " + fname + "\n"); } catch (Exception e) { String Error = "Error writing to " + fname + ". Exception: "; Log.e(TAG, Error, e); return false; } return true; }
From source file:Main.java
public static BufferedReader shellExecute(String[] commands, boolean requireRoot) { Process shell = null;//from w w w .j av a2s. co m DataOutputStream out = null; BufferedReader reader = null; String startCommand = requireRoot ? "su" : "sh"; try { shell = Runtime.getRuntime().exec(startCommand); out = new DataOutputStream(shell.getOutputStream()); reader = new BufferedReader(new InputStreamReader(shell.getInputStream())); for (String command : commands) { out.writeBytes(command + "\n"); out.flush(); } out.writeBytes("exit\n"); out.flush(); shell.waitFor(); } catch (Exception e) { Log.e(TAG, "ShellRoot#shExecute() finished with error", e); } finally { try { if (out != null) { out.close(); } } catch (Exception e) { } } return reader; }
From source file:Main.java
static JSONObject recordToJSON(NdefRecord record) { JSONObject json = new JSONObject(); try {//from w ww. ja v a 2 s . c om json.put("tnf", record.getTnf()); json.put("type", byteArrayToJSON(record.getType())); json.put("id", byteArrayToJSON(record.getId())); json.put("payload", byteArrayToJSON(record.getPayload())); } catch (JSONException e) { //Not sure why this would happen, documentation is unclear. Log.e(TAG, "Failed to convert ndef record into json: " + record.toString(), e); } return json; }
From source file:Main.java
@NonNull public static String getAppVersion(final Context context) { String versionName;//from w w w .j av a 2 s. c o m try { versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (final PackageManager.NameNotFoundException e) { Log.e(LOG_TAG, "Failed to get app version.", e); versionName = ""; } return versionName; }
From source file:Main.java
public static String fileReadOneLine(String fname) { BufferedReader br;//from w w w .j ava 2 s . c o m String line = null; try { br = new BufferedReader(new FileReader(fname), 512); try { line = br.readLine(); } finally { br.close(); } } catch (Exception e) { Log.e(TAG, "IO Exception when reading /sys/ file", e); } return line; }
From source file:Main.java
public static void e(String tag, String msg, Throwable tr) { if (ERROR) { Log.e(tag, msg, tr); } }
From source file:Main.java
public static Bitmap makeBitmap(String filePath, int maxNumOfPixels) { try {//from w w w . j a va2 s . c o m BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(filePath, options); if (options.mCancel || options.outWidth == -1 || options.outHeight == -1) { return null; } options.inSampleSize = computeSampleSize(options, -1, maxNumOfPixels); options.inJustDecodeBounds = false; options.inDither = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap b = BitmapFactory.decodeFile(filePath, options); b = formatBitmap(b, Math.min(options.outHeight, options.outWidth)); return b; } catch (OutOfMemoryError ex) { Log.e(TAG, "Got oom exception ", ex); return null; } }
From source file:Main.java
/** * This is an expensive operation that copies the image in place with the pixels rotated. * If possible rather use getOrientationMatrix, and set that as the imageMatrix on an ImageView. * * @param imageToOrient Image Bitmap to orient. * @param degreesToRotate number of degrees to rotate the image by. If zero the original image is returned unmodified. * @return The oriented bitmap. May be the imageToOrient without modification, or a new Bitmap. */// ww w .j a va2 s. c o m public static Bitmap rotateImage(Bitmap imageToOrient, int degreesToRotate) { try { if (degreesToRotate != 0) { Matrix matrix = new Matrix(); matrix.setRotate(degreesToRotate); imageToOrient = Bitmap.createBitmap(imageToOrient, 0, 0, imageToOrient.getWidth(), imageToOrient.getHeight(), matrix, true); } } catch (Exception e) { if (Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "Exception when trying to orient image", e); } e.printStackTrace(); } return imageToOrient; }