com.deploygate.sdk
Class DeployGate

java.lang.Object
  extended by com.deploygate.sdk.DeployGate

public class DeployGate
extends java.lang.Object

This is DeployGate SDK library. Import this library to the application package and call install(Application) 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.

Author:
tnj

Method Summary
static java.lang.String getLoginUsername()
          Get current DeployGate username.
static void install(Application app)
          Install DeployGate on your application instance.
static void install(Application app, DeployGateCallback callback)
          Install DeployGate on your application instance.
static void install(Application app, DeployGateCallback callback, boolean forceApplyOnReleaseBuild)
          Install DeployGate on your application instance.
static boolean isAuthorized()
          Get whether current DeployGate user has this application in his/her available list.
static boolean isDeployGateAvaliable()
          Get whether DeployGate client service is available on this device.
static boolean isInitialized()
          Get whether SDK is completed its intialization process and ready after install(Application).
static boolean isManaged()
          Get whether this application and its package is known and managed under the DeployGate.
static void logDebug(java.lang.String message)
          Record DEBUG level event on DeployGate.
static void logError(java.lang.String message)
          Record ERROR level event on DeployGate.
static void logInfo(java.lang.String message)
          Record INFO level event on DeployGate.
static void logVerbose(java.lang.String message)
          Record VERBOSE level event on DeployGate.
static void logWarn(java.lang.String message)
          Record WARN level event on DeployGate.
static void refresh()
          Request refreshing cached session values (e.g., isAuthorized, etc.) to the DeployGate service.
static void registerCallback(DeployGateCallback listener, boolean refreshImmediately)
          Register a DeployGate event callback listener.
static void unregisterCallback(DeployGateCallback listener)
          Unregister a callback listener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

install

public static void install(Application app)
Install DeployGate on your application instance. Call this method inside of your Application#onCreate().

Parameters:
app - Application instance, typically just pass this.

install

public static void install(Application app,
                           DeployGateCallback callback)
Install DeployGate on your application instance. Call this method inside of your Application#onCreate() once. On release build, which has android:isDebuggable set false on AndroidManifest.xml, this function will do nothing.

Parameters:
app - Application instance, typically just pass this.
callback - Callback interface to listen events.
Throws:
java.lang.IllegalStateException - if this called twice

install

public static void install(Application app,
                           DeployGateCallback callback,
                           boolean forceApplyOnReleaseBuild)
Install DeployGate on your application instance. Call this method inside of your Application#onCreate() once.

Parameters:
app - Application instance, typically just pass this.
callback - Callback interface to listen events.
forceApplyOnReleaseBuild - if you want to keep DeployGate alive on the release build, set this true.
Throws:
java.lang.IllegalStateException - if this called twice

refresh

public static void refresh()
Request refreshing cached session values (e.g., isAuthorized, etc.) to the DeployGate service. Nothing happens if this called before install(Application) or when refreshing is already in progress. Note that after calling this, isInitialized() will changed to false immediately and any call to is*() will be blocked until refreshing get finished.


registerCallback

public static void registerCallback(DeployGateCallback listener,
                                    boolean refreshImmediately)
Register a DeployGate event callback listener. Don't forget to call unregisterCallback(DeployGateCallback) 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:
listener - callback listener
refreshImmediately - if you want to receive current states, set this true.

unregisterCallback

public static void unregisterCallback(DeployGateCallback listener)
Unregister a callback listener. If the listener was not registered, just ignored.

Parameters:
listener - callback listener to be removed

isInitialized

public static boolean isInitialized()
Get whether SDK is completed its intialization process and ready after install(Application). This call will never blocked.

Returns:
true if SDK is ready. false otherwise. If no install() called ever, this always returns false.

isDeployGateAvaliable

public static boolean isDeployGateAvaliable()
Get whether DeployGate client service is available on this device.

Note this function will block until SDK get ready after install(Application) called. So if you want to call this function from the main thread, you should confirm that isInitialized() is true before calling this. (Or consider using DeployGateCallback.onInitialized(boolean) callback.)

Returns:
true if valid DeployGate client is available. false otherwise. If no install() called ever, this always returns false.

isManaged

public static boolean isManaged()
Get whether this application and its package is known and managed under the DeployGate.

Note this function will block until SDK get ready after install(Application) called. So if you want to call this function from the main thread, you should confirm that isInitialized() is true before calling this. (Or consider using DeployGateCallback.onInitialized(boolean) callback.)

Returns:
true if DeployGate knows and manages this package. false otherwise. If no install() called ever, this always returns false.

isAuthorized

public static boolean isAuthorized()
Get whether current DeployGate user has this application in his/her available list. You may want to check this value on initialization process of the main activity if you want to limit user of this application to only who you explicitly allowed.

Note this function will block until SDK get ready after install(Application) called. So if you want to call this function from the main thread, you should confirm that isInitialized() is true before calling this. (Or consider using DeployGateCallback.onInitialized(boolean) callback.)

Returns:
true if current DeployGate user has available list which contains this application. false otherwise. If no install() called ever, this always returns false.

getLoginUsername

public static java.lang.String getLoginUsername()
Get current DeployGate username.

Note this function will block until SDK get ready after install(Application) called. So if you want to call this function from the main thread, you should confirm that isInitialized() is true before calling this. (Or consider using DeployGateCallback.onInitialized(boolean) callback.)

Returns:
true if current DeployGate user has available list which contains this application. false otherwise. If no install() called ever, this always returns false.

logError

public static void logError(java.lang.String message)
Record ERROR level event on DeployGate. Log message will immediately send to the server so you may see it on your dashboard. Nothing happen when DeployGate is not available, i.e. isAuthorized() is not true.

Parameters:
message - Message body to be send. May be truncated if it's too long.

logWarn

public static void logWarn(java.lang.String message)
Record WARN level event on DeployGate. Log message will immediately send to the server so you may see it on your dashboard. Nothing happen when DeployGate is not available, i.e. isAuthorized() is not true.

Parameters:
message - Message body to be send. May be truncated if it's too long.

logDebug

public static void logDebug(java.lang.String message)
Record DEBUG level event on DeployGate. Log message will immediately send to the server so you may see it on your dashboard. Nothing happen when DeployGate is not available, i.e. isAuthorized() is not true.

Parameters:
message - Message body to be send. May be truncated if it's too long.

logInfo

public static void logInfo(java.lang.String message)
Record INFO level event on DeployGate. Log message will immediately send to the server so you may see it on your dashboard. Nothing happen when DeployGate is not available, i.e. isAuthorized() is not true.

Parameters:
message - Message body to be send. May be truncated if it's too long.

logVerbose

public static void logVerbose(java.lang.String message)
Record VERBOSE level event on DeployGate. Log message will immediately send to the server so you may see it on your dashboard. Nothing happen when DeployGate is not available, i.e. isAuthorized() is not true.

Parameters:
message - Message body to be send. May be truncated if it's too long.