Example usage for android.util Log getStackTraceString

List of usage examples for android.util Log getStackTraceString

Introduction

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

Prototype

public static String getStackTraceString(Throwable tr) 

Source Link

Document

Handy function to get a loggable stack trace from a Throwable

Usage

From source file:Main.java

public static void debug(Throwable e) {
    if (debug) {//from w  ww .  j  a va2 s .  co m
        String trace = Log.getStackTraceString(e);
        Log.w("AQuery", trace);
    }
}

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 {/*from  w  ww .ja v a2s. co  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(TAG, "Below API 19 cannot invoke!");
    }
    return false;
}

From source file:Main.java

public static String getStackTraceString(Throwable tr) {
    return Log.getStackTraceString(tr);
}

From source file:Main.java

public static void log(String tag, int level, Throwable t, Object... messages) {
    if (Log.isLoggable(tag, level)) {
        String message;/*from w  ww. j  ava 2 s .com*/
        if (t == null && messages != null && messages.length == 1) {
            // handle this common case without the extra cost of creating a stringbuffer:
            message = messages[0].toString();
        } else {
            StringBuilder sb = new StringBuilder();
            if (messages != null)
                for (Object m : messages) {
                    sb.append(m);
                }
            if (t != null) {
                sb.append("\n").append(Log.getStackTraceString(t));
            }
            message = sb.toString();
        }
        Log.println(level, tag, message);
    }
}

From source file:Main.java

private static void log(String tag, int level, Throwable t, Object... messages) {
    String message;/* w  ww .j a v  a 2  s .co m*/
    if (t == null && messages != null && messages.length == 1) {
        // handle this common case without the extra cost of creating a stringBuffer:
        message = messages[0].toString();
    } else {
        StringBuilder sb = new StringBuilder();
        if (messages != null)
            for (Object m : messages) {
                sb.append(m);
            }
        if (t != null) {
            sb.append("\n").append(Log.getStackTraceString(t));
        }
        message = sb.toString();
    }
    Log.println(level, tag, message);
}

From source file:info.papdt.blacklight.api.friendships.GroupsApi.java

public static GroupListModel getGroups() {
    WeiboParameters params = new WeiboParameters();

    try {/*from  ww w.j a  v  a2 s  .  co m*/
        JSONObject json = request(Constants.FRIENDSHIPS_GROUPS, params, HTTP_GET);
        return new Gson().fromJson(json.toString(), GroupListModel.class);
    } catch (Exception e) {
        if (DEBUG) {
            Log.e(TAG, "Cannot get groups");
            Log.e(TAG, Log.getStackTraceString(e));
        }
    }

    return null;
}

From source file:info.papdt.blacklight.api.statuses.HomeTimeLineApi.java

public static MessageListModel fetchHomeTimeLine(int count, int page) {
    WeiboParameters params = new WeiboParameters();
    params.put("count", count);
    params.put("page", page);

    try {//www  . j  a v a 2  s  .com
        JSONObject json = request(Constants.HOME_TIMELINE, params, HTTP_GET);
        return new Gson().fromJson(json.toString(), MessageListModel.class);
    } catch (Exception e) {
        if (DEBUG) {
            Log.d(TAG, "Cannot fetch home timeline, " + e.getClass().getSimpleName());
            Log.d(TAG, Log.getStackTraceString(e));
        }
        return null;
    }
}

From source file:info.papdt.blacklight.api.directmessages.DirectMessagesApi.java

public static DirectMessageUserListModel getUserList(int count, int cursor) {
    WeiboParameters params = new WeiboParameters();
    params.put("count", count);
    params.put("cursor", cursor);

    try {//from   w ww  . java2  s .c  o m
        JSONObject json = request(Constants.DIRECT_MESSAGES_USER_LIST, params, HTTP_GET);
        return new Gson().fromJson(json.toString(), DirectMessageUserListModel.class);
    } catch (Exception e) {
        if (DEBUG) {
            Log.e(TAG, Log.getStackTraceString(e));
        }
    }

    return null;
}

From source file:info.papdt.blacklight.api.friendships.FriendsApi.java

private static UserListModel getUsers(String uid, int count, int cursor, String url) {
    WeiboParameters params = new WeiboParameters();
    params.put("uid", uid);
    params.put("count", count);
    params.put("cursor", cursor);

    try {/*from   w  w  w .jav  a2  s .c o  m*/
        JSONObject json = request(url, params, HTTP_GET);
        return new Gson().fromJson(json.toString(), UserListModel.class);
    } catch (Exception e) {
        if (DEBUG) {
            Log.e(TAG, "Cannot get friends");
            Log.e(TAG, Log.getStackTraceString(e));
        }
    }

    return null;
}

From source file:info.papdt.blacklight.api.remind.RemindApi.java

public static UnreadModel getUnread(String uid) {
    WeiboParameters params = new WeiboParameters();
    params.put("uid", uid);
    params.put("unread_message", 0);

    try {//  w ww.j  ava 2s  .  co m
        JSONObject json = request(Constants.REMIND_UNREAD_COUNT, params, HTTP_GET);
        return new Gson().fromJson(json.toString(), UnreadModel.class);
    } catch (Exception e) {
        if (DEBUG) {
            Log.e(TAG, "Failed to get unread count");
            Log.e(TAG, Log.getStackTraceString(e));
        }
    }

    return null;
}