Package com.microsoft.appcenter.crashes
Class Crashes
- java.lang.Object
-
- com.microsoft.appcenter.AbstractAppCenterService
-
- com.microsoft.appcenter.crashes.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.AbstractAppCenterServiceCrashes service.
-
-
Field Summary
Fields Modifier and Type Field Description static intALWAYS_SENDConstant for ALWAYS SEND crash reports.static intDONT_SENDConstant for DO NOT SEND crash report.static java.lang.StringLOG_TAGTAG used in logging for Crashes.static java.lang.StringPREF_KEY_ALWAYS_SENDPreference storage key for ALWAYS SEND.static intSENDConstant for SEND crash report.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyEnabledState(boolean enabled)static voidgenerateTestCrash()Generates crash for test purpose.protected com.microsoft.appcenter.channel.Channel.GroupListenergetChannelListener()protected java.lang.StringgetGroupName()static CrashesgetInstance()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.StringgetLoggerTag()static com.microsoft.appcenter.utils.async.AppCenterFuture<java.lang.String>getMinidumpDirectory()Get the path where NDK minidump files should be created.java.lang.StringgetServiceName()protected intgetTriggerCount()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 voidnotifyUserConfirmation(int userConfirmation)Notifies SDK with a confirmation to handle the crash report.voidonStarted(android.content.Context context, com.microsoft.appcenter.channel.Channel channel, java.lang.String appSecret, java.lang.String transmissionTargetToken, boolean startedFromApp)java.util.UUIDsaveUncaughtException(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 voidsetListener(CrashesListener listener)Sets a crashes listener.static voidtrackError(java.lang.Throwable throwable)Track a handled error.static voidtrackError(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
-
SEND
public static final int SEND
Constant for SEND crash report.- See Also:
- Constant Field Values
-
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
trueif enabled,falseotherwise. - 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-trueto enable,falseto 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 ofSEND,DONT_SENDorALWAYS_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
trueif there was a crash in the last session,falseotherwise. - 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
trueif memory was running critically low,falseotherwise. - See Also:
AppCenterFuture
-
applyEnabledState
protected void applyEnabledState(boolean enabled)
- Overrides:
applyEnabledStatein classcom.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:
onStartedin interfacecom.microsoft.appcenter.AppCenterService- Overrides:
onStartedin classcom.microsoft.appcenter.AbstractAppCenterService
-
getLogFactories
public java.util.Map<java.lang.String,com.microsoft.appcenter.ingestion.models.json.LogFactory> getLogFactories()
- Specified by:
getLogFactoriesin interfacecom.microsoft.appcenter.AppCenterService- Overrides:
getLogFactoriesin classcom.microsoft.appcenter.AbstractAppCenterService
-
getGroupName
protected java.lang.String getGroupName()
- Specified by:
getGroupNamein classcom.microsoft.appcenter.AbstractAppCenterService
-
getServiceName
public java.lang.String getServiceName()
-
getLoggerTag
protected java.lang.String getLoggerTag()
- Specified by:
getLoggerTagin classcom.microsoft.appcenter.AbstractAppCenterService
-
getTriggerCount
protected int getTriggerCount()
- Overrides:
getTriggerCountin classcom.microsoft.appcenter.AbstractAppCenterService
-
getChannelListener
protected com.microsoft.appcenter.channel.Channel.GroupListener getChannelListener()
- Overrides:
getChannelListenerin classcom.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.
-
-