-
public class DeployGateThis is DeployGate SDK library. Import this library to the application package and call install on the onCreate() of application class to enable crash reporting and application launch notification.
In order to get working Remote LogCat feature, you also have to add
<uses-permission android:name="android.permission.READ_LOGS" />in AndroidManifest.xml of your application.
-
-
Method Summary
Modifier and Type Method Description static voidinstall(Context context, DeployGateSdkConfiguration sdkConfiguration)Install DeployGate on your application instance. static voidinstall(Application app)Install DeployGate on your application instance. static voidinstall(Application app, String author)Install DeployGate on your application instance. static voidinstall(Application app, DeployGateCallback callback)Install DeployGate on your application instance and register a callbacklistener. static voidinstall(Application app, boolean forceApplyOnReleaseBuild)Install DeployGate on your application instance and register a callbacklistener. static voidinstall(Application app, String author, DeployGateCallback callback)Install DeployGate on your application instance and register a callbacklistener. static voidinstall(Application app, DeployGateCallback callback, boolean forceApplyOnReleaseBuild)Install DeployGate on your application instance and register a callbacklistener. static voidinstall(Application app, String author, DeployGateCallback callback, boolean forceApplyOnReleaseBuild)Install DeployGate on your application instance and register a callbacklistener. static voidinstall(Application app, String author, DeployGateCallback callback, boolean forceApplyOnReleaseBuild, CustomLogConfiguration customLogConfiguration)Install DeployGate on your application instance and register a callbacklistener. static voidrefresh()Request refreshing cached session values (e.g., isAuthorized, etc.) tothe DeployGate service. static voidregisterInitializeCallback(DeployGateInitializeCallback callback)Register a callback listener about the DeployGate initialization event. static voidunregisterInitializeCallback(DeployGateInitializeCallback callback)Unregister a callback listener.If the listener was not registered, just ignored. static voidregisterStatusChangeCallback(DeployGateStatusChangeCallback callback)Register a callback listener about the app status on DeployGate. static voidunregisterStatusChangeCallback(DeployGateStatusChangeCallback callback)Unregister a callback listener.If the listener was not registered, just ignored. static voidregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback)Register a callback listener about the new version of the app is available. static voidunregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback)Unregister a callback listener.If the listener was not registered, just ignored. static voidregisterCaptureCreateCallback(DeployGateCaptureCreateCallback callback)Register a callback listener about the new capture is created.Don't forget to unregister the callback listener when it is no longer needed (e.g., on destroying an activity.)If the listener has already in the callback list, just ignored. static voidunregisterCaptureCreateCallback(DeployGateCaptureCreateCallback callback)Unregister a callback listener.If the listener was not registered, just ignored. static voidregisterCallback(DeployGateCallback listener, boolean refreshImmediately)Register a DeployGate event callback listener. static voidunregisterCallback(DeployGateCallback listener)Unregister a callback listener. static booleanisInitialized()Get whether SDK is completed its intialization process and ready after install. static booleanisDeployGateAvaliable()Get whether DeployGate client service is available on this device. static booleanisManaged()Get whether this application and its package is known and managed underthe DeployGate. static booleanisAuthorized()Get whether current DeployGate user has this application in his/heravailable list. static StringgetLoginUsername()Get current DeployGate username. static StringgetAuthorUsername()Get current app's author (e.g., User or Organzation) name on DeployGate. static voidlogError(String message)Record ERROR level event on DeployGate. static voidlogWarn(String message)Record WARN level event on DeployGate. static voidlogDebug(String message)Record DEBUG level event on DeployGate. static voidlogInfo(String message)Record INFO level event on DeployGate. static voidlogVerbose(String message)Record VERBOSE level event on DeployGate. static voidrequestLogCat()Capture current LogCat and send it. static intgetCurrentRevision()Returns the revision of the app on DeployGate.The revision number is automatically incremented integer value every time you upload a build to DeployGate,so you can identify the build explicitly. static StringgetDistributionUrl()Returns the URL of the distribution if the app was installed through Distribution Page. static StringgetDistributionId()Returns the ID (40 digits hex string appears in URL) of the distribution if the app was installed through Distribution Page. static StringgetDistributionTitle()Returns the title of the distribution if the app was installed through Distribution Page. static intgetDeployGateVersionCode()Use getDeployGateLongVersionCode static longgetDeployGateLongVersionCode()Returns android:versionCode of DeployGate app. static booleanhasUpdate()Check whether there's update of the app. static intgetUpdateRevision()Returns the revision number of the update. static intgetUpdateVersionCode()Returns the android:versionCode of the update. static StringgetUpdateVersionName()Returns the android:versionName of the update. static StringgetUpdateMessage()Returns the message attached to the build.If the app was installed via Distribution Page (i.e. static voidinstallUpdate()Start the installation of the latest version of the app if available. static voidopenComments()Open comments screen for the distribution of the app installed.No effect if the app was installed via Distribution Page (i.e. static voidcomposeComment()Open comment composer screen for the distribution of the app installed.No effect if the app was installed via Distribution Page (i.e. static voidcomposeComment(String defaultComment)Open comment composer screen for the distribution of the app installed with pre filled string.No effect if the app was installed via Distribution Page (i.e. static StringgetDistributionUserName()Get current user's name on Distribution Page. static CustomAttributesgetBuildEnvironment()static CustomAttributesgetRuntimeExtra()-
-
Method Detail
-
install
static void install(Context context, DeployGateSdkConfiguration sdkConfiguration)
Install DeployGate on your application instance. Call this method insideof your onCreate, in ContentProvider or AndroidX Startup Initializer only once.
- Parameters:
context- Your application's Context.sdkConfiguration- sdk configuration DeployGateSdkConfiguration
-
install
static void install(Application app)
Install DeployGate on your application instance. Call this method insideof your onCreate once.
On a release build, which has
android:isDebuggableset false onAndroidManifest.xml, this function will do nothing. If you want to enableDeployGate on a release build, consider using install instead.Note: To make isAuthorized more effective, you shouldcall install instead and specify authorIdexplicitly to ensure the authority of this app to prevent casualredistribution via DeployGate.
- Parameters:
app- Application instance, typically just pass this.
-
install
static void install(Application app, String author)
Install DeployGate on your application instance. Call this method insideof your onCreate once.
On a release build, which has
android:isDebuggableset false onAndroidManifest.xml, this function will do nothing. If you want to enableDeployGate on a release build, consider using install instead.- Parameters:
app- Application instance, typically just pass this.author- author username of this app.
-
install
static void install(Application app, DeployGateCallback callback)
Install DeployGate on your application instance and register a callbacklistener. Call this method inside of your onCreate once.
On a release build, which has
android:isDebuggableset false onAndroidManifest.xml, this function will do nothing. If you want to enableDeployGate on a release build, consider using install instead.Note: To make isAuthorized more effective, you shouldcall install instead and specify authorIdexplicitly to ensure the authority of this app to prevent casualredistribution via DeployGate.
- Parameters:
app- Application instance, typically just pass this.callback- Callback interface to listen events.
-
install
static void install(Application app, boolean forceApplyOnReleaseBuild)
Install DeployGate on your application instance and register a callbacklistener. Call this method inside of your onCreate once.
Note: To make isAuthorized more effective, you shouldcall install instead and specify authorIdexplicitly to ensure the authority of this app to prevent casualredistribution via DeployGate.
- Parameters:
app- Application instance, typically just pass this.forceApplyOnReleaseBuild- if you want to keep DeployGate alive onthe release build, set this true.
-
install
static void install(Application app, String author, DeployGateCallback callback)
Install DeployGate on your application instance and register a callbacklistener. Call this method inside of your onCreate once.
On a release build, which has
android:isDebuggableset false onAndroidManifest.xml, this function will do nothing. If you want to enableDeployGate on a release build, consider using install instead.- Parameters:
app- Application instance, typically just pass this.author- author username of this app.callback- Callback interface to listen events.
-
install
static void install(Application app, DeployGateCallback callback, boolean forceApplyOnReleaseBuild)
Install DeployGate on your application instance and register a callbacklistener. Call this method inside of your onCreate once.
Note: To make isAuthorized more effective, you shouldcall install instead and specify authorIdexplicitly to ensure the authority of this app to prevent casualredistribution via DeployGate.
- Parameters:
app- Application instance, typically just pass this.callback- Callback interface to listen events.forceApplyOnReleaseBuild- if you want to keep DeployGate alive onthe release build, set this true.
-
install
static void install(Application app, String author, DeployGateCallback callback, boolean forceApplyOnReleaseBuild)
Install DeployGate on your application instance and register a callbacklistener. Call this method inside of your onCreate once.
- Parameters:
app- Application instance, typically just pass this.author- author username of this app.callback- Callback interface to listen events.forceApplyOnReleaseBuild- if you want to keep DeployGate alive onthe release build, set this true.
-
install
static void install(Application app, String author, DeployGateCallback callback, boolean forceApplyOnReleaseBuild, CustomLogConfiguration customLogConfiguration)
Install DeployGate on your application instance and register a callbacklistener. Call this method inside of your onCreate once.
- Parameters:
app- Application instance, typically just pass this.author- author username of this app.callback- Callback interface to listen events.forceApplyOnReleaseBuild- if you want to keep DeployGate alive onthe release build, set this true.customLogConfiguration- set a configuration for custom logging
-
refresh
static void refresh()
Request refreshing cached session values (e.g., isAuthorized, etc.) tothe DeployGate service. Nothing happens if this called before install or when refreshing is already in progress.Note that after calling this, isInitialized will changed tofalse immediately and any call to
is*()will be blocked untilrefreshing get finished.
-
registerInitializeCallback
static void registerInitializeCallback(DeployGateInitializeCallback callback)
Register a callback listener about the DeployGate initialization event.Don't forget to call unregisterInitializeCallback when the callback is no longer needed (e.g., on destroying an activity.)If the listener has already in the callback list, just ignored.
- Parameters:
callback- callback listener
-
unregisterInitializeCallback
static void unregisterInitializeCallback(DeployGateInitializeCallback callback)
Unregister a callback listener.If the listener was not registered, just ignored.
- Parameters:
callback- callback listener to be removed
-
registerStatusChangeCallback
static void registerStatusChangeCallback(DeployGateStatusChangeCallback callback)
Register a callback listener about the app status on DeployGate.Don't forget to call unregisterStatusChangeCallback when the callback is no longer needed (e.g., on destroying an activity.)If the listener has already in the callback list, just ignored.
- Parameters:
callback- callback listener
-
unregisterStatusChangeCallback
static void unregisterStatusChangeCallback(DeployGateStatusChangeCallback callback)
Unregister a callback listener.If the listener was not registered, just ignored.
- Parameters:
callback- callback listener to be removed
-
registerUpdateAvailableCallback
static void registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback)
Register a callback listener about the new version of the app is available.Don't forget to call unregisterUpdateAvailableCallback when the callback is no longer needed (e.g., on destroying an activity.)If the listener has already in the callback list, just ignored.
- Parameters:
callback- callback listener
-
unregisterUpdateAvailableCallback
static void unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback)
Unregister a callback listener.If the listener was not registered, just ignored.
- Parameters:
callback- callback listener to be removed
-
registerCaptureCreateCallback
static void registerCaptureCreateCallback(DeployGateCaptureCreateCallback callback)
Register a callback listener about the new capture is created.Don't forget to unregister the callback listener when it is no longer needed (e.g., on destroying an activity.)If the listener has already in the callback list, just ignored.
- Parameters:
callback- callback listener
-
unregisterCaptureCreateCallback
static void unregisterCaptureCreateCallback(DeployGateCaptureCreateCallback callback)
Unregister a callback listener.If the listener was not registered, just ignored.
- Parameters:
callback- callback listener to be removed
-
registerCallback
@Deprecated() static void registerCallback(DeployGateCallback listener, boolean refreshImmediately)
Register a DeployGate event callback listener. Don't forget to call unregisterCallback when the callback is nolonger needed (e.g., on destroying an activity.) If the listener hasalready in the callback list, just ignored.
- Parameters:
listener- callback listenerrefreshImmediately- if you want to receive current states, set thistrue.
-
unregisterCallback
@Deprecated() static void unregisterCallback(DeployGateCallback listener)
Unregister a callback listener. If the listener was not registered, justignored.
- Parameters:
listener- callback listener to be removed
-
isInitialized
static boolean isInitialized()
Get whether SDK is completed its intialization process and ready after install. This call will never blocked.
-
isDeployGateAvaliable
static boolean isDeployGateAvaliable()
Get whether DeployGate client service is available on this device.
Note this function will block until SDK get ready after install called. So if you want to call thisfunction from the main thread, you should confirm that isInitialized is true before calling this. (Or consider using onInitialized callback.)
-
isManaged
static boolean isManaged()
Get whether this application and its package is known and managed underthe DeployGate.
Note this function will block until SDK get ready after install called. So if you want to call thisfunction from the main thread, you should confirm that isInitialized is true before calling this. (Or consider using onInitialized callback.)
-
isAuthorized
static boolean isAuthorized()
Get whether current DeployGate user has this application in his/heravailable list. You may want to check this value on initializationprocess of the main activity if you want to limit user of thisapplication to only who you explicitly allowed.
Note this function will block until SDK get ready after install called. So if you want to call thisfunction from the main thread, you should confirm that isInitialized is true before calling this. (Or consider using onInitialized callback.)
-
getLoginUsername
static String getLoginUsername()
Get current DeployGate username. This function only available when isAuthorized is true.
Note this function will block until SDK get ready after install called. So if you want to call thisfunction from the main thread, you should confirm that isInitialized is true before calling this. (Or consider using onInitialized callback.)
-
getAuthorUsername
static String getAuthorUsername()
Get current app's author (e.g., User or Organzation) name on DeployGate. Youmay use this value to check the app was distributed by yourself orsomeone else.
Tip: If you want to prevent distributing your app by someone elseon the DeployGate, consider using install.
Note this function will block until SDK get ready after install called. So if you want to call thisfunction from the main thread, you should confirm that isInitialized is true before calling this. (Or consider using onInitialized callback.)
-
logError
static void logError(String message)
Record ERROR level event on DeployGate. Log message will immediately sendto the server so you may see it on your dashboard. Nothing happen whenDeployGate is not available, i.e. isAuthorized is not true.
- Parameters:
message- Message body to be send.
-
logWarn
static void logWarn(String message)
Record WARN level event on DeployGate. Log message will immediately sendto the server so you may see it on your dashboard. Nothing happen whenDeployGate is not available, i.e. isAuthorized is not true.
- Parameters:
message- Message body to be send.
-
logDebug
static void logDebug(String message)
Record DEBUG level event on DeployGate. Log message will immediately sendto the server so you may see it on your dashboard. Nothing happen whenDeployGate is not available, i.e. isAuthorized is not true.
- Parameters:
message- Message body to be send.
-
logInfo
static void logInfo(String message)
Record INFO level event on DeployGate. Log message will immediately sendto the server so you may see it on your dashboard. Nothing happen whenDeployGate is not available, i.e. isAuthorized is not true.
- Parameters:
message- Message body to be send.
-
logVerbose
static void logVerbose(String message)
Record VERBOSE level event on DeployGate. Log message will immediatelysend to the server so you may see it on your dashboard. Nothing happenwhen DeployGate is not available, i.e. isAuthorized is nottrue.
- Parameters:
message- Message body to be send.
-
requestLogCat
static void requestLogCat()
Capture current LogCat and send it. This call will work asynchronously.Capturing LogCat requires
android.permission.READ_LOGSisdeclared on your app AndroidManifest.xml, or your app is running onAndroid 4.1 or higher. If LogCat is not available, this function simplydoes nothing.
-
getCurrentRevision
static int getCurrentRevision()
Returns the revision of the app on DeployGate.The revision number is automatically incremented integer value every time you upload a build to DeployGate,so you can identify the build explicitly.
Requires DeployGate v1.7.0 or higher installed, otherwise this function always returns 0.
-
getDistributionUrl
static String getDistributionUrl()
Returns the URL of the distribution if the app was installed through Distribution Page.
Requires DeployGate v1.7.0 or higher installed, otherwise this function always returns null.
-
getDistributionId
static String getDistributionId()
Returns the ID (40 digits hex string appears in URL) of the distribution if the app was installed through Distribution Page.
Requires DeployGate v1.7.0 or higher installed, otherwise this function always returns null.
-
getDistributionTitle
static String getDistributionTitle()
Returns the title of the distribution if the app was installed through Distribution Page.
Requires DeployGate v1.7.0 or higher installed, otherwise this function always returns null.
-
getDeployGateVersionCode
@Deprecated() static int getDeployGateVersionCode()
-
getDeployGateLongVersionCode
static long getDeployGateLongVersionCode()
Returns android:versionCode of DeployGate app.
-
hasUpdate
static boolean hasUpdate()
Check whether there's update of the app.You can get detailed information via getUpdateRevision, getUpdateVersionCode, getUpdateVersionName, and getUpdateMessage.
-
getUpdateRevision
static int getUpdateRevision()
Returns the revision number of the update. The value is only valid when hasUpdate is true.
-
getUpdateVersionCode
static int getUpdateVersionCode()
Returns the android:versionCode of the update. The value is only valid when hasUpdate is true.
-
getUpdateVersionName
static String getUpdateVersionName()
Returns the android:versionName of the update. The value is only valid when hasUpdate is true.
-
getUpdateMessage
static String getUpdateMessage()
Returns the message attached to the build.If the app was installed via Distribution Page (i.e. is not null, this method returns Release Note that was entered when you published a new version on the page.Otherwise this method returns the message that was entered when you upload a new build to DeployGate.
Requires DeployGate v1.7.0 or higher installed, otherwise this function always returns null.
-
installUpdate
static void installUpdate()
Start the installation of the latest version of the app if available. No effects if there's no update.
Requires DeployGate v1.7.0 or higher installed, otherwise this function produces no effect.
-
openComments
static void openComments()
Open comments screen for the distribution of the app installed.No effect if the app was installed via Distribution Page (i.e. is null.
Requires DeployGate v1.7.0 or higher installed, otherwise this function produces no effect.
-
composeComment
static void composeComment()
Open comment composer screen for the distribution of the app installed.No effect if the app was installed via Distribution Page (i.e. is null.
Requires DeployGate v1.7.0 or higher installed, otherwise this function produces no effect.
-
composeComment
static void composeComment(String defaultComment)
Open comment composer screen for the distribution of the app installed with pre filled string.No effect if the app was installed via Distribution Page (i.e. is null.
Requires DeployGate v1.7.0 or higher installed, otherwise this function produces no effect.
- Parameters:
defaultComment- Default comment set to the editor
-
getDistributionUserName
static String getDistributionUserName()
Get current user's name on Distribution Page. Default name is randomly generated string (like "[abcd1234]").
Requires DeployGate v1.7.0 or higher installed, otherwise this function returns null.
-
getBuildEnvironment
static CustomAttributes getBuildEnvironment()
-
getRuntimeExtra
static CustomAttributes getRuntimeExtra()
-
-
-
-