Class Crashes

  • All Implemented Interfaces:
    android.app.Application.ActivityLifecycleCallbacks, com.microsoft.appcenter.AppCenterService, com.microsoft.appcenter.utils.ApplicationLifecycleListener.ApplicationLifecycleCallbacks

    public class Crashes
    extends com.microsoft.appcenter.AbstractAppCenterService
    Crashes service.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALWAYS_SEND
      Constant for ALWAYS SEND crash reports.
      static int DONT_SEND
      Constant for DO NOT SEND crash report.
      static java.lang.String LOG_TAG
      TAG used in logging for Crashes.
      static java.lang.String PREF_KEY_ALWAYS_SEND
      Preference storage key for ALWAYS SEND.
      static int SEND
      Constant for SEND crash report.
      • Fields inherited from class com.microsoft.appcenter.AbstractAppCenterService

        mChannel
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void applyEnabledState​(boolean enabled)  
      static void generateTestCrash()
      Generates crash for test purpose.
      protected com.microsoft.appcenter.channel.Channel.GroupListener getChannelListener()  
      protected java.lang.String getGroupName()  
      static Crashes getInstance()  
      static com.microsoft.appcenter.utils.async.AppCenterFuture<ErrorReport> getLastSessionCrashReport()
      Provides information about any available crash report from the last session, if it crashed.
      java.util.Map<java.lang.String,​com.microsoft.appcenter.ingestion.models.json.LogFactory> getLogFactories()  
      protected java.lang.String getLoggerTag()  
      static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.String> getMinidumpDirectory()
      Get the path where NDK minidump files should be created.
      java.lang.String getServiceName()  
      protected int getTriggerCount()  
      static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.Boolean> hasCrashedInLastSession()
      Check whether the app crashed in its last session.
      static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.Boolean> hasReceivedMemoryWarningInLastSession()
      Check whether there was a memory warning in the last session.
      static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.Boolean> isEnabled()
      Check whether Crashes service is enabled or not.
      static void notifyUserConfirmation​(int userConfirmation)
      Notifies SDK with a confirmation to handle the crash report.
      void onStarted​(android.content.Context context, com.microsoft.appcenter.channel.Channel channel, java.lang.String appSecret, java.lang.String transmissionTargetToken, boolean startedFromApp)  
      java.util.UUID saveUncaughtException​(java.lang.Thread thread, java.lang.Throwable throwable)
      Save a crash.
      static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.Void> setEnabled​(boolean enabled)
      Enable or disable Crashes service.
      static void setListener​(CrashesListener listener)
      Sets a crashes listener.
      static void trackError​(java.lang.Throwable throwable)
      Track a handled error.
      static void trackError​(java.lang.Throwable throwable, java.util.Map<java.lang.String,​java.lang.String> properties, java.lang.Iterable<ErrorAttachmentLog> attachments)
      Track a handled error with name and optional properties and attachments.
      • Methods inherited from class com.microsoft.appcenter.AbstractAppCenterService

        getEnabledPreferenceKey, getTriggerInterval, getTriggerMaxParallelRequests, isAppSecretRequired, isInstanceEnabled, isInstanceEnabledAsync, isStarted, onActivityCreated, onActivityDestroyed, onActivityPaused, onActivityResumed, onActivitySaveInstanceState, onActivityStarted, onActivityStopped, onApplicationEnterBackground, onApplicationEnterForeground, onConfigurationUpdated, onStarting, post, post, postAsyncGetter, setInstanceEnabled, setInstanceEnabledAsync
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface android.app.Application.ActivityLifecycleCallbacks

        onActivityPostCreated, onActivityPostDestroyed, onActivityPostPaused, onActivityPostResumed, onActivityPostSaveInstanceState, onActivityPostStarted, onActivityPostStopped, onActivityPreCreated, onActivityPreDestroyed, onActivityPrePaused, onActivityPreResumed, onActivityPreSaveInstanceState, onActivityPreStarted, onActivityPreStopped
    • Field Detail

      • DONT_SEND

        public static final int DONT_SEND
        Constant for DO NOT SEND crash report.
        See Also:
        Constant Field Values
      • ALWAYS_SEND

        public static final int ALWAYS_SEND
        Constant for ALWAYS SEND crash reports.
        See Also:
        Constant Field Values
      • PREF_KEY_ALWAYS_SEND

        public static final java.lang.String PREF_KEY_ALWAYS_SEND
        Preference storage key for ALWAYS SEND.
        See Also:
        Constant Field Values
      • LOG_TAG

        public static final java.lang.String LOG_TAG
        TAG used in logging for Crashes.
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        @NonNull
        public static Crashes getInstance()
      • isEnabled

        public static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.Boolean> isEnabled()
        Check whether Crashes service is enabled or not.
        Returns:
        future with result being true if enabled, false otherwise.
        See Also:
        AppCenterFuture
      • setEnabled

        public static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.Void> setEnabled​(boolean enabled)
        Enable or disable Crashes service.

        The state is persisted in the device's storage across application launches.

        Parameters:
        enabled - true to enable, false to disable.
        Returns:
        future with null result to monitor when the operation completes.
      • trackError

        public static void trackError​(@NonNull
                                      java.lang.Throwable throwable)
        Track a handled error.
        Parameters:
        throwable - The throwable describing the handled error.
      • trackError

        public static void trackError​(@NonNull
                                      java.lang.Throwable throwable,
                                      java.util.Map<java.lang.String,​java.lang.String> properties,
                                      java.lang.Iterable<ErrorAttachmentLog> attachments)
        Track a handled error with name and optional properties and attachments. The name parameter can not be null or empty. Maximum allowed length = 256. The properties parameter maximum item count = 5. The properties keys can not be null or empty, maximum allowed key length = 64. The properties values can not be null, maximum allowed value length = 64. Any length of name/keys/values that are longer than each limit will be truncated.
        Parameters:
        throwable - The throwable describing the handled error.
        properties - Optional properties.
        attachments - Optional attachments.
      • generateTestCrash

        public static void generateTestCrash()
        Generates crash for test purpose.
      • setListener

        public static void setListener​(CrashesListener listener)
        Sets a crashes listener.
        Parameters:
        listener - The custom crashes listener.
      • getMinidumpDirectory

        public static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.String> getMinidumpDirectory()
        Get the path where NDK minidump files should be created.

        Returns:
        path where minidump files should be created.
      • notifyUserConfirmation

        public static void notifyUserConfirmation​(int userConfirmation)
        Notifies SDK with a confirmation to handle the crash report.
        Parameters:
        userConfirmation - A user confirmation. Should be one of SEND, DONT_SEND or ALWAYS_SEND
        See Also:
        SEND, DONT_SEND, ALWAYS_SEND
      • hasCrashedInLastSession

        public static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.Boolean> hasCrashedInLastSession()
        Check whether the app crashed in its last session.
        Returns:
        future with result being true if there was a crash in the last session, false otherwise.
        See Also:
        AppCenterFuture
      • getLastSessionCrashReport

        public static com.microsoft.appcenter.utils.async.AppCenterFuture<ErrorReport> getLastSessionCrashReport()
        Provides information about any available crash report from the last session, if it crashed.
        Returns:
        future with result being the crash report from last session or null if there wasn't one.
        See Also:
        AppCenterFuture
      • hasReceivedMemoryWarningInLastSession

        public static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.Boolean> hasReceivedMemoryWarningInLastSession()
        Check whether there was a memory warning in the last session.
        Returns:
        future with result being true if memory was running critically low, false otherwise.
        See Also:
        AppCenterFuture
      • applyEnabledState

        protected void applyEnabledState​(boolean enabled)
        Overrides:
        applyEnabledState in class com.microsoft.appcenter.AbstractAppCenterService
      • onStarted

        public void onStarted​(@NonNull
                              android.content.Context context,
                              @NonNull
                              com.microsoft.appcenter.channel.Channel channel,
                              java.lang.String appSecret,
                              java.lang.String transmissionTargetToken,
                              boolean startedFromApp)
        Specified by:
        onStarted in interface com.microsoft.appcenter.AppCenterService
        Overrides:
        onStarted in class com.microsoft.appcenter.AbstractAppCenterService
      • getLogFactories

        public java.util.Map<java.lang.String,​com.microsoft.appcenter.ingestion.models.json.LogFactory> getLogFactories()
        Specified by:
        getLogFactories in interface com.microsoft.appcenter.AppCenterService
        Overrides:
        getLogFactories in class com.microsoft.appcenter.AbstractAppCenterService
      • getGroupName

        protected java.lang.String getGroupName()
        Specified by:
        getGroupName in class com.microsoft.appcenter.AbstractAppCenterService
      • getServiceName

        public java.lang.String getServiceName()
      • getLoggerTag

        protected java.lang.String getLoggerTag()
        Specified by:
        getLoggerTag in class com.microsoft.appcenter.AbstractAppCenterService
      • getTriggerCount

        protected int getTriggerCount()
        Overrides:
        getTriggerCount in class com.microsoft.appcenter.AbstractAppCenterService
      • getChannelListener

        protected com.microsoft.appcenter.channel.Channel.GroupListener getChannelListener()
        Overrides:
        getChannelListener in class com.microsoft.appcenter.AbstractAppCenterService
      • saveUncaughtException

        public java.util.UUID saveUncaughtException​(java.lang.Thread thread,
                                                    java.lang.Throwable throwable)
        Save a crash.
        Parameters:
        thread - thread where crash occurred.
        throwable - uncaught exception or error.
        Returns:
        UUID uncaught exception's UUID.