List of usage examples for android.util Log e
public static int e(String tag, String msg)
From source file:Main.java
public static void showLog(long info) { Log.e("TAG", String.valueOf(info)); }
From source file:Main.java
static String get(String endpoint) throws IOException { URL url;//from w ww . j a v a 2 s . c o m String html = ""; Logd(TAG, "Starting post..."); Boolean cont = true; try { url = new URL(endpoint); } catch (MalformedURLException e) { Log.e(TAG, "Invalid url: " + endpoint); cont = false; throw new IllegalArgumentException("Invalid url: " + endpoint); } if (cont) { html = validGet(url); } else { html = "Bad url"; } return html; }
From source file:Main.java
public static void logTime(final String event, final long time) { Log.e("Timer", event + " use time: " + time); }
From source file:Main.java
static String downloadUrl(String myurl) throws IOException { InputStream is = null;//from w ww .j a v a2 s. c om try { URL url = new URL(myurl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Authorization", "Basic cm9vdDpvcmllbnRkYg=="); conn.setReadTimeout(10000); conn.setConnectTimeout(15000); conn.setRequestMethod("GET"); conn.setDoInput(true); //start conn.connect(); int response = conn.getResponseCode(); Log.e("The response is: ", "" + response); is = conn.getInputStream(); //converte inputStream in stringa String contentAsString = readIt(is); return contentAsString; } catch (IOException e) { Log.e("HTTP", e.getMessage()); return null; } finally { if (is != null) { is.close(); } } }
From source file:Main.java
static public Document getDomElement(String xml) { Document doc = null;/*from www. j a v a 2 s . co m*/ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); //Set the input to our xml string InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xml)); doc = db.parse(is); } catch (ParserConfigurationException e) { Log.e("Error: ", e.getMessage()); return null; } catch (SAXException e) { Log.e("Error: ", e.getMessage()); return null; } catch (IOException e) { Log.e("Error: ", e.getMessage()); return null; } //return DOM return doc; }
From source file:Main.java
public static String getLocalIpAddress() { try {/*from w w w. j av a 2 s. c o m*/ for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en .hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress()) { return inetAddress.getHostAddress().toString(); } } } } catch (SocketException ex) { Log.e("WifiPreference IpAddress", ex.toString()); } return null; }
From source file:Main.java
public static String getLocalIpAddress() { try {// w ww. j a v a2 s . c o m for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en .hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { return inetAddress.getHostAddress(); } } } } catch (SocketException ex) { Log.e(TAG, ex.toString()); } return null; }
From source file:Main.java
public static Bitmap fromYUV420P(byte[] yuv, int width, int height) { if (yuv == null) { Log.e(TAG, "yuv data==null"); return null; }//from ww w . j a v a 2 s .com if (yuv.length != width * height * 1.5) { Log.e(TAG, "yudData does not match the provided width and height"); return null; } Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); int offsetY = 0; ShortBuffer buffer = ShortBuffer.allocate(width * height * 2); for (int line = 0; line < height; line++) { for (int col = 0; col < width; col++) { int y = yuv[offsetY++] & 0xFF; buffer.put((short) ((y >> 3) << 11 | (y >> 2) << 5 | (y >> 3))); } } bitmap.copyPixelsFromBuffer(buffer); return bitmap; }
From source file:Main.java
public static Bitmap CreateBitmap(View v) { if (v == null) { Log.e(TAG, "View is null. Cannot create bitmap"); return null; }/*from ww w . ja v a2 s .c o m*/ v.setDrawingCacheEnabled(true); v.buildDrawingCache(); Bitmap bitmap = null; try { bitmap = Bitmap.createBitmap(v.getDrawingCache()); } catch (Exception e) { Log.e(TAG, "Unable to create bitmap"); } v.destroyDrawingCache(); v.setDrawingCacheEnabled(false); return bitmap; }
From source file:Main.java
private static void copyFile(AssetManager assetManager, String filename, String destination) { InputStream in = null;//from www .j a v a2 s . com OutputStream out = null; try { in = assetManager.open(filename); String newFileName = destination + File.separator + filename; out = new FileOutputStream(newFileName); byte[] buffer = new byte[1024]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } in.close(); in = null; out.flush(); out.close(); out = null; } catch (Exception e) { Log.e("tag", e.getMessage()); } }