Example usage for android.util Log e

List of usage examples for android.util Log e

Introduction

In this page you can find the example usage for android.util Log e.

Prototype

public static int e(String tag, String msg) 

Source Link

Document

Send an #ERROR log message.

Usage

From source file:Main.java

public static List<String> fileReader(Context context, int rawId) {
    Resources myRes = context.getResources();
    String data = null;//www. ja v  a  2  s. c  om
    List<String> list = new ArrayList<String>();

    BufferedReader br = null;
    try {
        br = new BufferedReader(new InputStreamReader(myRes.openRawResource(rawId)));

        do {
            data = br.readLine();
            if (data == null) {
                break;
            }
            list.add(data);
            //Log.i(TAG, data);
        } while (true);

    } catch (Exception e) {
        e.printStackTrace();
        Log.e(TAG, e.getMessage());
    }

    return list;
}

From source file:Main.java

public static String getMetaValue(Context context, String metaKey) {
    Bundle metaData = null;/*  ww w  .ja  v a  2 s .c  o m*/
    String apiKey = null;
    if (context == null || metaKey == null) {
        return null;
    }
    try {
        ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA);
        if (null != ai) {
            metaData = ai.metaData;
        }
        if (null != metaData) {
            apiKey = metaData.getString(metaKey);
        }
    } catch (NameNotFoundException e) {
        Log.e(TAG, "error " + e.getMessage());
    }
    return apiKey;
}

From source file:Main.java

/** Create the EasyRPG's directories in path it's possible */
public static boolean createEasyRPGDirectories(String path) {
    //Main folder
    File dir = new File(path);
    dir.mkdir();//from  www  .  ja va 2 s  .co  m

    //Games' folder
    File dirGames = new File(dir, "games/");
    dirGames.mkdir();

    //RTP's folders
    File dirRtp = new File(dir, "rtp/");
    dirRtp.mkdir();
    File dirRtp2000 = new File(dirRtp, "2000");
    dirRtp2000.mkdir();
    File dirRtp2003 = new File(dirRtp, "2003");
    dirRtp2003.mkdir();

    // The .nomedia file (to not let app scan games and RTP's folders)
    File nomediafile = new File(dir, ".nomedia");
    try {
        nomediafile.createNewFile();
    } catch (IOException e) {
        Log.e("Create File", "Error creating .nomedia file");
    }

    //TODO : Verify if all the folders exists
    return true;
}

From source file:Main.java

public static String findJniLibrary(Context context, String libName) {
    String result = null;/*from  w  w  w.  j  ava2s  .  co  m*/
    ClassLoader classLoader = (context.getClassLoader());
    if (classLoader != null) {
        try {
            Method findLibraryMethod = classLoader.getClass().getMethod("findLibrary",
                    new Class<?>[] { String.class });
            if (findLibraryMethod != null) {
                Object objPath = findLibraryMethod.invoke(classLoader, new Object[] { libName });
                if (objPath != null && objPath instanceof String) {
                    result = (String) objPath;
                }
            }
        } catch (Exception e) {
            Log.e(TAG, e.toString());
        }
    }

    return result;
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= 19) {
        AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        try {/*  w w  w . ja va  2  s. c o  m*/
            Class clazz = AppOpsManager.class;
            Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
            return AppOpsManager.MODE_ALLOWED == (int) method.invoke(manager, op, Binder.getCallingUid(),
                    context.getPackageName());
        } catch (Exception e) {
            Log.e(TAG, Log.getStackTraceString(e));
        }
    } else {
        Log.e("", "Below API 19 cannot invoke!");
    }
    return false;
}

From source file:Main.java

public static void showLog(double info) {
    Log.e("TAG", String.valueOf(info));
}

From source file:Main.java

public static Bitmap getCompressedBitmap(InputStream is, int sampleSize) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = sampleSize;/*from  ww  w .  ja  va  2s  .co  m*/
    try {
        return BitmapFactory.decodeStream(is, null, options);
    } catch (OutOfMemoryError e) {
        Log.e("talktab.error", "OutOfMemoryError");
        options.inSampleSize = sampleSize * 2;
        return BitmapFactory.decodeStream(is, null, options);
    }
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static Map<String, String> convertFromJSONToMap(String str) {
    Map<String, String> map = new HashMap<String, String>();
    if (isNullOrEmpty(str) == false) {
        try {/*from   w  w  w .j av a2  s .c o  m*/
            JSONObject json = new JSONObject(str);
            Iterator<String> keys = json.keys();
            while (keys.hasNext()) {
                String key = keys.next();
                String val = json.getString(key);
                map.put(key, val);
            }
        } catch (JSONException e) {
            Log.e(TAG, "convertFromCXX to org.json.JSONArray " + str);
        }
    }
    return map;
}

From source file:Main.java

public static Integer parseInt(Object value, Object defValue) {
    if (null == value) {
        return parseInt(defValue, 0);
    }/*from w  ww  .  j  av a2s  . c  o  m*/

    try {
        return Integer.parseInt(value.toString());
    } catch (Exception e) {
        Log.e("NumberFormatException", "Integer format Exception...");
        return parseInt(defValue, 0);
    }
}

From source file:Main.java

public static String normalizeUrl(String sourceUrl) {
    String normalizedUrl = "";
    try {//w ww.jav a 2 s  .  c om
        URL url = new URL(sourceUrl);
        normalizedUrl = url.toString();
        normalizedUrl = normalizedUrl.replace("\n", "");
        normalizedUrl = normalizedUrl.replace(" ", "");
        if (!normalizedUrl.endsWith("/"))
            normalizedUrl = normalizedUrl + "/";
    } catch (MalformedURLException e) {
        Log.e(TAG, "normalizeUrl: invalid URL");
    }
    return normalizedUrl;
}