List of usage examples for android.util Log e
public static int e(String tag, String msg)
From source file:Main.java
public static int setupProgram(String vxShaderCode, String frShaderCode) { int mProgram; int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vxShaderCode); int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, frShaderCode); if (vertexShader == 0 || fragmentShader == 0) { throw new RuntimeException("shader not loaded"); }/*from www. j a v a2 s. c o m*/ mProgram = GLES20.glCreateProgram(); // create empty OpenGL ES Program GLES20.glAttachShader(mProgram, vertexShader); // add the vertex shader // to program GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment // shader to program GLES20.glLinkProgram(mProgram); int[] linkStatus = new int[1]; GLES20.glGetProgramiv(mProgram, GLES20.GL_LINK_STATUS, linkStatus, 0); if (linkStatus[0] != GLES20.GL_TRUE) { Log.e("jay", "Could not link program: "); Log.e("jay", GLES20.glGetProgramInfoLog(mProgram)); GLES20.glDeleteProgram(mProgram); mProgram = 0; } return mProgram; }
From source file:Main.java
public static String UpdateScore(String userName, int br) { String retStr = ""; try {/*from w w w . j a va2 s. c om*/ URL url = new URL("http://" + IP_ADDRESS + "/RiddleQuizApp/ServerSide/AzurirajHighScore.php"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(15000); conn.setReadTimeout(10000); conn.setRequestMethod("POST"); conn.setDoInput(true); conn.setDoOutput(true); Log.e("http", "por1"); JSONObject data = new JSONObject(); data.put("username", userName); data.put("broj", br); Log.e("http", "por3"); Uri.Builder builder = new Uri.Builder().appendQueryParameter("action", data.toString()); String query = builder.build().getEncodedQuery(); Log.e("http", "por4"); OutputStream os = conn.getOutputStream(); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, "UTF-8")); bw.write(query); Log.e("http", "por5"); bw.flush(); bw.close(); os.close(); int responseCode = conn.getResponseCode(); Log.e("http", String.valueOf(responseCode)); if (responseCode == HttpURLConnection.HTTP_OK) { retStr = inputStreamToString(conn.getInputStream()); } else retStr = String.valueOf("Error: " + responseCode); Log.e("http", retStr); } catch (Exception e) { Log.e("http", "greska"); } return retStr; }
From source file:Main.java
public static void logProgressReport(Context c, String[] logs) { String dir = c.getExternalFilesDir(null).getParent(); try {// w w w . j a v a 2 s .c o m File file = new File(dir + "/sf_reports.log"); boolean append = false; // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } else { /* if(file.length() >= 2097152){ // set log file max size to 2mb append = false; } */ } FileOutputStream fos = new FileOutputStream(file, append); for (String log : logs) { fos.write((log + "\n\n").getBytes()); } fos.close(); } catch (IOException ioe) { Log.e("AndroidUtils", "An exception has occured in logProgressReport!"); ioe.printStackTrace(); } }
From source file:Main.java
/** * Generates an encryption key for devices with API level lower than 18 using the * ANDROID_ID value as a seed./*from w w w. j a va 2s . c om*/ * In production scenarios, you should come up with your own implementation of this method. * Consider that your algorithm must return the same key so it can encrypt/decrypt values * successfully. * * @return The encryption key in a 32 byte long array. */ private static byte[] generateSecretKey() { byte[] key = new byte[32]; byte[] android_id = null; try { android_id = Settings.Secure.ANDROID_ID.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { Log.e(TAG, "generateSecretKey - " + e.getMessage()); } for (int i = 0; i < key.length; i++) { key[i] = android_id[i % android_id.length]; } return key; }
From source file:Main.java
public static String UdatePlayerBT(String userName, String device) { String retStr = ""; try {//from w w w .j a va 2s .c o m URL url = new URL("http://" + IP_ADDRESS + "/RiddleQuizApp/ServerSide/PostaviBTdevice.php"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(15000); conn.setReadTimeout(10000); conn.setRequestMethod("POST"); conn.setDoInput(true); conn.setDoOutput(true); Log.e("http", "por1"); JSONObject data = new JSONObject(); data.put("username", userName); data.put("bt_device", device); Log.e("http", "por3"); Uri.Builder builder = new Uri.Builder().appendQueryParameter("action", data.toString()); String query = builder.build().getEncodedQuery(); Log.e("http", "por4"); OutputStream os = conn.getOutputStream(); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, "UTF-8")); bw.write(query); Log.e("http", "por5"); bw.flush(); bw.close(); os.close(); int responseCode = conn.getResponseCode(); Log.e("http", String.valueOf(responseCode)); if (responseCode == HttpURLConnection.HTTP_OK) { retStr = inputStreamToString(conn.getInputStream()); } else retStr = String.valueOf("Error: " + responseCode); Log.e("http", retStr); } catch (Exception e) { Log.e("http", "greska"); } return retStr; }
From source file:Main.java
public static void closeSilently(Object... xs) { // Note: on Android API levels prior to 19 Socket does not implement Closeable for (Object x : xs) { if (x != null) { try { Log.d(TAG, "closing: " + x); if (x instanceof Closeable) { ((Closeable) x).close(); } else if (x instanceof Socket) { ((Socket) x).close(); } else if (x instanceof DatagramSocket) { ((DatagramSocket) x).close(); } else { Log.d(TAG, "cannot close: " + x); throw new RuntimeException("cannot close " + x); }//from w w w . j a va 2 s . c om } catch (Throwable e) { Log.e(TAG, e.getMessage()); } } } }
From source file:Main.java
public static Object invoke(Object receiver, Object defaultValue, Method method, Object... args) { if (method == null) return defaultValue; try {//from w ww. j a va 2 s. c o m return method.invoke(receiver, args); } catch (Exception e) { Log.e(TAG, "Exception in invoke: " + e.getClass().getSimpleName()); } return defaultValue; }
From source file:Main.java
public static InputStream fileToInputStream(final String fileName) throws FileNotFoundException { File file = new File(fileName); if (!file.exists()) { Log.e(TAG_CLASS, fileName + " not found."); return null; }//from ww w . j a v a2 s.c o m return new FileInputStream(file); }
From source file:Main.java
public static void e(String tag, String msg) { if (ERROR) { Log.e(tag, msg); } }
From source file:Main.java
/** * @param bitmap Bitmap that will be processed * @return The average color of the input bitmap *//*www . ja va 2 s. com*/ public static int getAverageColor(Bitmap bitmap) { if (bitmap == null) { Log.e("getAverageColor()", "ERROR: No bitmap generated to get average colour from."); return Color.BLACK; } int redBucket = 0; int greenBucket = 0; int blueBucket = 0; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int pixelCount = 0; int c = 0; for (int y = 0; y < height; y += STEP_SIZE_PIXEL) { for (int x = 0; x < width; x += STEP_SIZE_PIXEL) { c = bitmap.getPixel(x, y); redBucket += Color.red(c); greenBucket += Color.green(c); blueBucket += Color.blue(c); pixelCount++; } redBucket += Color.red(c); } return Color.rgb(redBucket / pixelCount, greenBucket / pixelCount, blueBucket / pixelCount); }