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:org.alfresco.mobile.android.application.fragments.builder.FragmentBuilderFactory.java

private static AlfrescoFragmentBuilder createBaseViewConfig(String className, FragmentActivity activity,
        Map<String, Object> configuration) {
    AlfrescoFragmentBuilder s = null;//from w  w w . java 2 s. c  o m
    try {
        Constructor<?> t = Class.forName(className).getDeclaredConstructor(FragmentActivity.class, Map.class);
        s = (AlfrescoFragmentBuilder) t.newInstance(activity, configuration);
    } catch (Exception e) {
        Log.e(TAG, Log.getStackTraceString(e));
        Log.e(TAG, "Error during BaseViewConfig creation : " + className);
    }
    return s;
}

From source file:org.alfresco.mobile.android.application.exception.CloudExceptionUtils.java

public static void handleCloudException(Context context, Long accountId, Exception exception,
        boolean forceRefresh) {
    Log.w(TAG, Log.getStackTraceString(exception));
    if (exception instanceof AlfrescoSessionException) {
        AlfrescoSessionException ex = ((AlfrescoSessionException) exception);
        switch (ex.getErrorCode()) {
        case ErrorCodeRegistry.SESSION_API_KEYS_INVALID:
        case ErrorCodeRegistry.SESSION_REFRESH_TOKEN_EXPIRED:
            manageException(context, forceRefresh);
            return;
        default://from w w w . ja va2s.  co  m
            if (ex.getMessage().contains("No authentication challenges found") || ex.getErrorCode() == 100) {
                manageException(context, forceRefresh);
                return;
            }
            break;
        }
    }

    if (exception instanceof AlfrescoServiceException) {
        AlfrescoServiceException ex = ((AlfrescoServiceException) exception);
        if ((ex.getErrorCode() == 104 || (ex.getMessage() != null
                && ex.getMessage().contains("No authentication challenges found")))) {
            manageException(context, forceRefresh);
            return;
        } else {
            Bundle b = new Bundle();
            b.putInt(SimpleAlertDialogFragment.PARAM_ICON, R.drawable.ic_alfresco_logo);
            b.putInt(SimpleAlertDialogFragment.PARAM_TITLE, R.string.error_general_title);
            b.putInt(SimpleAlertDialogFragment.PARAM_POSITIVE_BUTTON, android.R.string.ok);
            b.putInt(SimpleAlertDialogFragment.PARAM_MESSAGE,
                    SessionExceptionHelper.getMessageId(context, exception));
            ActionManager.actionDisplayDialog(context, b);
            return;
        }
    }

    if (exception instanceof CmisConnectionException) {
        CmisConnectionException ex = ((CmisConnectionException) exception);
        if (ex.getMessage().contains("No authentication challenges found")) {
            manageException(context, forceRefresh);
            return;
        }
    }

    if (exception instanceof AlfrescoSessionException) {
        int messageId = R.string.error_session_notfound;
        AlfrescoSessionException se = ((AlfrescoSessionException) exception);
        if (se.getErrorCode() == ErrorCodeRegistry.GENERAL_HTTP_RESP && se.getMessage() != null
                && se.getMessage().contains(HttpStatus.SC_SERVICE_UNAVAILABLE + "")) {
            messageId = R.string.error_session_cloud_unavailable;
        }

        Intent broadcastIntent = new Intent();
        broadcastIntent.setAction(IntentIntegrator.ACTION_LOAD_ACCOUNT_ERROR);
        broadcastIntent.putExtra(SimpleAlertDialogFragment.PARAM_ICON, R.drawable.ic_alfresco_logo);
        broadcastIntent.putExtra(SimpleAlertDialogFragment.PARAM_TITLE,
                R.string.error_session_creation_message);
        broadcastIntent.putExtra(SimpleAlertDialogFragment.PARAM_POSITIVE_BUTTON, android.R.string.ok);
        broadcastIntent.putExtra(SimpleAlertDialogFragment.PARAM_MESSAGE, messageId);
        if (accountId != null) {
            broadcastIntent.putExtra(IntentIntegrator.EXTRA_ACCOUNT_ID, accountId);
        }
        LocalBroadcastManager.getInstance(context).sendBroadcast(broadcastIntent);
        return;
    }
}

From source file:info.papdt.blacklight.api.comments.CommentTimeLineApi.java

public static CommentListModel fetchCommentTimeLineSince(long id) {
    WeiboParameters params = new WeiboParameters();
    params.put("since_id", id);

    try {/*from w  w w .j  ava  2  s.c om*/
        JSONObject json = request(Constants.COMMENTS_TIMELINE, params, HTTP_GET);
        return new Gson().fromJson(json.toString(), CommentListModel.class);
    } catch (Exception e) {
        if (DEBUG) {
            Log.e(TAG, Log.getStackTraceString(e));
        }
        return null;
    }
}

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

public static boolean isMember(String uid, String groupId) {
    WeiboParameters params = new WeiboParameters();
    params.put("uid", uid);
    params.put("list_id", groupId);

    try {//www .j  a  va2  s  .  c o m
        JSONObject json = request(Constants.FRIENDSHIPS_GROUPS_IS_MEMBER, params, HTTP_GET);
        return json.optBoolean("lists");
    } catch (Exception e) {
        if (DEBUG) {
            Log.e(TAG, "Cannot determine if user is a member");
            Log.e(TAG, Log.getStackTraceString(e));
        }
    }

    return false;
}

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

public static DirectMessageListModel getConversation(String uid, int count, int page) {
    WeiboParameters params = new WeiboParameters();
    params.put("uid", uid);
    params.put("count", count);
    params.put("page", page);

    try {//from  ww  w  .j  a  v  a2s  . c  om
        JSONObject json = request(Constants.DIRECT_MESSAGES_CONVERSATION, params, HTTP_GET);
        return new Gson().fromJson(json.toString(), DirectMessageListModel.class);
    } catch (Exception e) {
        if (DEBUG) {
            Log.d(TAG, Log.getStackTraceString(e));
        }
    }

    return null;
}

From source file:org.alfresco.mobile.android.platform.exception.CloudExceptionUtils.java

public static void handleCloudException(Context context, Long accountId, Exception exception,
        boolean forceRefresh, String taskId) {
    Log.w(TAG, Log.getStackTraceString(exception));
    if (exception instanceof AlfrescoSessionException) {
        AlfrescoSessionException ex = ((AlfrescoSessionException) exception);
        switch (ex.getErrorCode()) {
        case ErrorCodeRegistry.SESSION_API_KEYS_INVALID:
        case ErrorCodeRegistry.SESSION_REFRESH_TOKEN_EXPIRED:
            requestOAuthAuthentication(context, accountId, taskId, forceRefresh);
            return;
        default://from w  w  w  . ja v  a 2s.co m
            if (ex.getMessage().contains("No authentication challenges found") || ex.getErrorCode() == 100) {
                requestOAuthAuthentication(context, accountId, taskId, forceRefresh);
                return;
            }
            break;
        }
    }

    if (exception instanceof AlfrescoServiceException) {
        AlfrescoServiceException ex = ((AlfrescoServiceException) exception);
        if ((ex.getErrorCode() == 104 || (ex.getMessage() != null
                && ex.getMessage().contains("No authentication challenges found")))) {
            requestOAuthAuthentication(context, accountId, taskId, forceRefresh);
            return;
        } else {
            Bundle b = new Bundle();
            b.putInt(SimpleAlertDialogFragment.ARGUMENT_ICON, R.drawable.ic_application_logo);
            b.putInt(SimpleAlertDialogFragment.ARGUMENT_TITLE, R.string.error_general_title);
            b.putInt(SimpleAlertDialogFragment.ARGUMENT_POSITIVE_BUTTON, android.R.string.ok);
            b.putInt(SimpleAlertDialogFragment.ARGUMENT_MESSAGE,
                    AlfrescoExceptionHelper.getMessageId(context, exception));
            BaseActionUtils.actionDisplayDialog(context, b);
            return;
        }
    }

    if (exception instanceof CmisConnectionException) {
        CmisConnectionException ex = ((CmisConnectionException) exception);
        if (ex.getMessage().contains("No authentication challenges found")) {
            requestOAuthAuthentication(context, accountId, taskId, forceRefresh);
            return;
        }
    }

    if (exception instanceof AlfrescoSessionException) {
        int messageId = R.string.error_session_notfound;
        AlfrescoSessionException se = ((AlfrescoSessionException) exception);
        if (se.getErrorCode() == ErrorCodeRegistry.GENERAL_HTTP_RESP && se.getMessage() != null
                && se.getMessage().contains(HttpStatus.SC_SERVICE_UNAVAILABLE + "")) {
            messageId = R.string.error_session_cloud_unavailable;
        }

        EventBusManager.getInstance().post(new LoadAccountErrorEvent(null, accountId, exception, messageId));
    }
}

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

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

    try {/*ww  w .  java 2 s. c  o  m*/
        JSONObject json = request(Constants.BILATERAL_TIMELINE, params, HTTP_GET);
        return new Gson().fromJson(json.toString(), MessageListModel.class);
    } catch (Exception e) {
        if (DEBUG) {
            Log.d(TAG, "Cannot fetch bilateral timeline, " + e.getClass().getSimpleName());
            Log.d(TAG, Log.getStackTraceString(e));
        }
        return null;
    }
}

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

public static void clearUnread(String type) {
    WeiboParameters params = new WeiboParameters();
    params.put("type", type);

    try {//from   www.  j a  v  a  2s . com
        request(Constants.REMIND_UNREAD_SET_COUNT, params, HTTP_POST);
    } catch (Exception e) {
        if (DEBUG) {
            Log.e(TAG, "Cannot clear unread count");
            Log.e(TAG, Log.getStackTraceString(e));
        }
    }
}

From source file:com.dm.material.dashboard.candybar.helpers.RequestHelper.java

@NonNull
private static String loadAppFilter(@NonNull Context context) {
    try {// w w w . j a  va2 s.c  o m
        StringBuilder sb = new StringBuilder();
        XmlPullParser xpp = context.getResources().getXml(R.xml.appfilter);

        while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) {
            if (xpp.getEventType() == XmlPullParser.START_TAG) {
                if (xpp.getName().equals("item")) {
                    sb.append(xpp.getAttributeValue(null, "component"));
                }
            }
            xpp.next();
        }
        return sb.toString();
    } catch (Exception e) {
        LogUtil.e(Log.getStackTraceString(e));
    }
    return "";
}

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

public static boolean send(String uid, String text) {
    WeiboParameters params = new WeiboParameters();
    params.put("uid", uid);
    params.put("text", text);

    try {// www  . j  av a2  s.c o m
        request(Constants.DIRECT_MESSAGES_SEND, params, HTTP_POST);
        return true;
    } catch (Exception e) {
        if (DEBUG) {
            Log.d(TAG, Log.getStackTraceString(e));
        }
    }

    return false;
}