List of usage examples for android.util Log e
public static int e(String tag, String msg)
From source file:Main.java
public static boolean hasActiveInternetConnection(Context context) { if (isNetworkAvailable(context)) { try {/*from ww w . j a v a2s. c o m*/ HttpURLConnection connection = (HttpURLConnection) (new URL( "http://clients3.google.com/generate_204")).openConnection(); connection.setRequestProperty("User-Agent", "Test"); connection.setRequestProperty("Connection", "close"); connection.setReadTimeout(1500); connection.connect(); return (connection.getResponseCode() == 204 && connection.getContentLength() == 0); } catch (IOException e) { Log.e("ERROR", "Error checking internet connection"); } } else Log.e("ERROR", "No network available"); return false; }
From source file:Main.java
/** * /*w w w . j a va2 s .com*/ * @param aFile * @return */ public static String getLastLines(String filename, int number) { File aFile = new File(filename); StringBuilder contents = new StringBuilder(); LinkedList<String> ll = new LinkedList<String>(); try { BufferedReader input = new BufferedReader(new FileReader(aFile)); try { String line = null; while ((line = input.readLine()) != null) { ll.add(line); } } finally { input.close(); } } catch (IOException ex) { Log.e(TAG, ex.getMessage()); } if ((ll.size() - number) <= 0) { Log.e(TAG, "Requested number of lines exceeds lines of file"); return "Requested number of lines exceeds lines of file"; } for (int i = (ll.size() - 1); i >= (ll.size() - number); i--) { contents.append(ll.get(i - 1)); contents.append("\n"); } return contents.toString(); }
From source file:Main.java
/** * Return camera instance// w ww . j ava 2 s . c om */ public static Camera getCameraInstance(int displayOrientation) { Camera cam = null; try { cam = Camera.open(); // More efficient way to find available cameras. Nexus 7 needs this. if (cam == null) { int availableCameras = Camera.getNumberOfCameras(); for (int i = 0; i < availableCameras; i++) { cam = Camera.open(i); if (cam != null) break; } } cam.setDisplayOrientation(displayOrientation); Log.d(TAG, "Getting Camera: " + cam.toString()); } catch (Exception e) { Log.e(TAG, "Camera is not available (in use or does not exist)"); Log.e(TAG, e.toString()); } return cam; }
From source file:Main.java
public static String getJsonWithPath(String path) { StringBuffer sb = new StringBuffer(); URL url = null;//from w ww . j a v a 2 s.c o m HttpURLConnection conn = null; BufferedReader br = null; try { url = new URL(path); conn = (HttpURLConnection) url.openConnection(); if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String temp = ""; while ((temp = br.readLine()) != null) { sb.append(temp); } } else { Log.e(TAG, " NET IS ERROR"); } } catch (Exception e) { e.printStackTrace(); } finally { close(br); conn.disconnect(); } Log.i("TAG", "---" + sb.toString()); return sb.toString(); }
From source file:Main.java
public static void loge(String msg) { if (!debug) { return;//from ww w . j av a 2s . co m } Log.e("ldx", "" + msg); }
From source file:Main.java
public static void saveBitmap(Bitmap b) { String path = initPath();//w w w .j av a 2 s . com SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMMdd-hhmmss"); String dataTake = sDateFormat.format(System.currentTimeMillis()); String jpegName = path + "/" + "myImage.jpg"; try { Log.e(TAG, "save pic"); FileOutputStream fout = new FileOutputStream(jpegName); BufferedOutputStream bos = new BufferedOutputStream(fout); b.compress(Bitmap.CompressFormat.JPEG, 100, bos); bos.flush(); bos.close(); } catch (IOException e) { e.printStackTrace(); Log.e(TAG, e.toString()); } Log.e("camera", "pic saved jpegName: " + jpegName); }
From source file:Main.java
/** * Creates Log Error message according to given tag and message. * * @param tag the name of the class whose instance called this function * @param message error message to output to log *//*from ww w . ja v a 2s . co m*/ public static void LogError(String tag, String message) { Log.e(tag, message); }
From source file:Main.java
public static void removeExternalFile(String path, String logTag) { File file = new File(path); if (file.exists()) { boolean isDeleted = file.delete(); if (!isDeleted) { Log.e(logTag, "failed to delete " + path); }/*from w w w .j a v a2 s .c o m*/ } }
From source file:com.goodway.nominatimparser.Request.java
public static void getPlaces(Action a, ArrayList<Pair>... parameters) { try {//from w w w .j ava 2s .c o m new GetPlaces(a, parameters).execute(); Log.d("getPlaces", "getPlaces"); } catch (IllegalStateException e) { Log.e(e.getMessage(), "exception"); } }
From source file:Main.java
public static void getEulerAngles(float[] headView, float[] output) { float pitch = (float) Math.asin((double) headView[6]); float yaw;/*from w w w . jav a 2 s . co m*/ float roll; if (Math.abs(headView[6]) < 0.9999999999D) { yaw = (float) Math.atan2((double) (-headView[2]), (double) headView[10]); roll = (float) Math.atan2((double) (-headView[4]), (double) headView[5]); } else { yaw = 0.0F; roll = (float) Math.atan2((double) headView[1], (double) headView[0]); } output[0] = -pitch; output[1] = -yaw; output[2] = -roll; float pitchAngle = (float) Math.toDegrees(output[0]); float yawAngle = (float) Math.toDegrees(output[1]); float rollAngle = (float) Math.toDegrees(output[2]); Log.e(TAG, String.format("pitchAngle=%f, yawAngle=%f, rollAngle=%f", pitchAngle, yawAngle, rollAngle)); }