public abstract class

A4S

extends Object
java.lang.Object
   ↳ com.ad4screen.sdk.A4S

Class Overview

Root class presenting Ad4Screen SDK functionalities.

Summary

Nested Classes
interface A4S.Callback<T> Callback used to return an operation result asynchronously 
interface A4S.MessageCallback Callback used to return an Inbox Message asynchronously 
Public Methods
static void disableTracking(Context context, boolean forceFlush)
Disable Tracking for SDK.
abstract void displayInApp(String id)
To be used in conjunction with setInAppReadyCallback and only if manuallyAllowDisplay is set to true
Tell the SDK to display an in-app in a template
Only in-app allowed to be displayed in the specified template will be displayed
static void enableTracking(Context context)
Enable Tracking for SDK if it were previously disabled using disableTracking(Context, boolean).
static A4S get(Context context)
Retrieves Ad4Screen API singleton object.
abstract void getA4SId(Callback<String> callback)
Returns Ad4Screen user ID trough a callback if user was assigned an ID or null otherwise.
abstract String getAndroidId()
Returns Android (Secure) Id trough a callback if any or empty string otherwise.
abstract void getIDFV(Callback<String> callback)
Returns A4S generated IDFV.
abstract void getInbox(Callback<Inbox> callback)
Retrieve all messages that belong to users
abstract void getListOfSubscriptions(Callback<List<StaticList>> callback)
Returns the subscribed lists
abstract void getSubscriptionStatusForLists(List<StaticList> staticList, Callback<List<StaticList>> callback)
Allow you to know the subscription status for some lists
static boolean isDoNotTrackEnabled(Context context)
Deprecated Use isTrackingEnabled(Context) instead.
abstract void isGCMEnabled(Callback<Boolean> callback)
static boolean isInA4SProcess(Context context)
Call this function to determine if current process is dedicated to Ad4Screen service.
abstract void isInAppDisplayLocked(Callback<Boolean> callback)
Returns whether InApp display is allowed or not trough a callback.
abstract void isPushEnabled(Callback<Boolean> callback)
Returns whether SDK is allowed to use GCM or ADM to notify the user with push notifications
Note This function may return true even if user is not registered due to GCM or ADM restriction.
abstract boolean isPushNotificationLocked()
Returns whether RichPush display is allowed or not.
abstract void isRestrictedConnection(Callback<Boolean> callback)
Returns whether SDK is allowed to use the internet connection
static boolean isTrackingEnabled(Context context)
Allows you to know if SDK Tracking is enabled and therefore the SDK current status.
abstract void putState(String name, String value)
Sets or remove a client-side state to a given value.
abstract void resetOverlayPosition()
Reset overlay position for displayed in-app using overlay
abstract void sendGCMToken(String token)
Deprecated : Please use sendPushToken
Send a GCM Token to Accengage Servers If you are retrieving GCM token by yourself, use this method to send obtained token to Accengage Servers As soon as a valid token has been sended, you will be able to Push from Accengage interface
abstract void sendPushToken(String token)
Send a Push Token to Accengage Servers If you are retrieving a GCM or ADM token by yourself, use this method to send obtained token to Accengage Servers As soon as a valid token has been sended, you will be able to Push from Accengage interface
static void setDoNotTrackEnabled(Context context, boolean enabled)
abstract void setGCMEnabled(boolean enabled)
abstract void setInAppClickedCallback(Callback<InApp> inAppClickedCallback, int... layout)
Set a callback to be called when an in-app (banner) is clicked
Please note that any call to this method will replace any previous call

You should call this method just before calling A4S.get(this).startActivity() or super.onCreate() or you can lock in-app display using setInAppDisplayLocked, call this method and finally unlock in-app display.
abstract void setInAppClosedCallback(Callback<InApp> inAppClosedCallback, int... layout)
Set a callback to be called when an in-app (banner) is displayed
Please note that any call to this method will replace any previous call

You should call this method just before calling A4S.get(this).startActivity() or super.onCreate() or you can lock in-app display using setInAppDisplayLocked, call this method and finally unlock in-app display.
abstract void setInAppDisplayLocked(boolean locked)
Allows you to allow or prevent InApp visual elements to be displayed.
abstract void setInAppDisplayedCallback(Callback<InApp> inAppDisplayedCallback, int... layout)
Set a callback to be called when an in-app (banner) is closed
Please note that any call to this method will replace any previous call

You should call this method just before calling A4S.get(this).startActivity() or super.onCreate() or you can lock in-app display using setInAppDisplayLocked, call this method and finally unlock in-app display.
abstract void setInAppReadyCallback(boolean manuallyAllowDisplay, Callback<InApp> inAppReadyCallback, int... layout)
Set a callback to be called when an in-app (banner) is ready to be displayed
Please note that any call to this method will replace any previous call

Optionally : you can ask the SDK to not display any in-app by setting manuallyAllowDisplay to true
In this case, you will have to call displayInApp(template) in order to display a ready in-app in a template

You should call this method just before calling A4S.get(this).startActivity() or super.onCreate() or you can lock in-app display using setInAppDisplayLocked, call this method and finally unlock in-app display.
abstract void setIntent(Intent intent)
Function to be called by client application when onNewIntent method is called in your Activity Lifecycle
abstract void setOverlayPosition(FrameLayout.LayoutParams layoutParams)
Set overlay position for displayed in-app using overlay
This position will never change until you call this method again specifying new position
Default : FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM)
You can use : Gravity.TOP, Gravity.CENTER or Gravity.BOTTOM
abstract void setPushEnabled(boolean enabled)
Enables or disables Push notifications for this device.
abstract void setPushNotificationLocked(boolean locked)
Allows you to allow or prevent Landing Page of Push Notifications to be displayed.
abstract void setRestrictedConnection(boolean restricted)
Allows or disallows SDK to use Internet Connection.
abstract void setView(String viewName)
Set the name of the view which is currently displayed to user You can use this to override a Tag annotation (when you are using FragmentActivity with multiple views for instance)
abstract void startActivity(Activity activity)
Function to be called by client application when any activity is resumed
abstract void stopActivity(Activity activity)
Function to be called by client application when any activity is paused
abstract void subscribeToLists(StaticList... staticLists)
Allow you to subscribe the device user to a list
abstract void subscribeToLists(List<StaticList> staticLists)
Allow you to subscribe the device user to a list
abstract void trackAddToCart(Cart cart)
Send an item to add to a given cart to Ad4screen Servers
abstract void trackEvent(long eventId, String... eventArgs)
Sends an event with its accompanying information to Ad4Screen servers.
abstract void trackLead(Lead lead)
Send a lead to Ad4Screen Servers
abstract void trackPurchase(Purchase purchase)
Send a purchase with or without items to Ad4Screen Servers
abstract void unsubscribeFromLists(List<StaticList> staticLists)
Allow you to cancel the device user subscription
abstract void unsubscribeFromLists(StaticList... staticLists)
Allow you to cancel the device user subscription to a list
abstract void updateDeviceInfo(Bundle bundle)
Send user data to Accengage servers to update this device information.
abstract void updateGeolocation(Location location)
Send a new Geolocation to Accengage Servers Use this method if you are using no-geoloc meta-data and you need to manually update geolocation of this device Please note that you can send a new Geolocation only once by 5 minutes
abstract void updateMessages(Inbox inbox)
Send an update of read/unread status and archive status for this inbox to Ad4screen Servers
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void disableTracking (Context context, boolean forceFlush)

Disable Tracking for SDK.
As most features cannot work while tracking is disabled, calling this method will completely disable SDK (you will still receive push notifications). The shutdown may take some time. After this every call to any API will be void until enableTracking is called.
Important Use with care! this will disable all SDK features.

Parameters
context Your application package context.
forceFlush True to send currently cached requests to server False to delete all cached requests

public abstract void displayInApp (String id)

To be used in conjunction with setInAppReadyCallback and only if manuallyAllowDisplay is set to true
Tell the SDK to display an in-app in a template
Only in-app allowed to be displayed in the specified template will be displayed

Parameters
id of the in-app to be displayed
You should store the id value received inside the callback defined in setInAppReadyCallback and re-use it here

public static void enableTracking (Context context)

Enable Tracking for SDK if it were previously disabled using disableTracking(Context, boolean).
Important Use with care! this will enable all SDK features.

Parameters
context Your application package context.

public static A4S get (Context context)

Retrieves Ad4Screen API singleton object.

Parameters
context Your application package context.
Returns
  • The Ad4Screen API singleton object in this process.

public abstract void getA4SId (Callback<String> callback)

Returns Ad4Screen user ID trough a callback if user was assigned an ID or null otherwise. Note this function is asynchronous. Warning The ID may be null until user was tracked once by the server.

Parameters
callback The callback to return user ID trough

public abstract String getAndroidId ()

Returns Android (Secure) Id trough a callback if any or empty string otherwise. Note this function is asynchronous.

public abstract void getIDFV (Callback<String> callback)

Returns A4S generated IDFV. Note this function is asynchronous.

Parameters
callback The callback to return the IDFV through

public abstract void getInbox (Callback<Inbox> callback)

Retrieve all messages that belong to users

Parameters
callback Return the Inbox with all the messages of these users

public abstract void getListOfSubscriptions (Callback<List<StaticList>> callback)

Returns the subscribed lists

Parameters
callback Callback to call with current subscribed lists

public abstract void getSubscriptionStatusForLists (List<StaticList> staticList, Callback<List<StaticList>> callback)

Allow you to know the subscription status for some lists

Parameters
staticList List of Static Lists for which you want to retrieve the status
callback Callback to call with status result

public static boolean isDoNotTrackEnabled (Context context)

public abstract void isGCMEnabled (Callback<Boolean> callback)

public static boolean isInA4SProcess (Context context)

Call this function to determine if current process is dedicated to Ad4Screen service.
Important You should not perform work in Ad4Screen dedicated process in most cases.
Usage

 if (A4S.isInA4SProcess(this)) {
     return;
 }
 // perform my work
 

Parameters
context Your application package context.
Returns
  • true if current process is dedicated to Ad4Screen Service. False if current process is client application process.

public abstract void isInAppDisplayLocked (Callback<Boolean> callback)

Returns whether InApp display is allowed or not trough a callback. Note This function is asynchronous.

Parameters
callback The callback to return the result trough.

public abstract void isPushEnabled (Callback<Boolean> callback)

Returns whether SDK is allowed to use GCM or ADM to notify the user with push notifications
Note This function may return true even if user is not registered due to GCM or ADM restriction. This function only tells you that SDK is allowed to try to register user.

Parameters
callback Returns true trough callback if GCM use is allowed, false otherwise.

public abstract boolean isPushNotificationLocked ()

Returns whether RichPush display is allowed or not.

public abstract void isRestrictedConnection (Callback<Boolean> callback)

Returns whether SDK is allowed to use the internet connection

Parameters
callback Returns true trough callback if Internet Connextion use is not restricted, false otherwise.

public static boolean isTrackingEnabled (Context context)

Allows you to know if SDK Tracking is enabled and therefore the SDK current status.

Parameters
context Your application package context.
Returns
  • True if tracking is enabled and False if SDK Tracking is disabled.

public abstract void putState (String name, String value)

Sets or remove a client-side state to a given value. Think of states like browser cookies which can be used to trigger Accengage inapp notifications.

Parameters
name The name of the state to set or update
value The value for this state or null to remove the state.

public abstract void resetOverlayPosition ()

Reset overlay position for displayed in-app using overlay

public abstract void sendGCMToken (String token)

Deprecated : Please use sendPushToken
Send a GCM Token to Accengage Servers If you are retrieving GCM token by yourself, use this method to send obtained token to Accengage Servers As soon as a valid token has been sended, you will be able to Push from Accengage interface

Parameters
token GCM token returned from registration process

public abstract void sendPushToken (String token)

Send a Push Token to Accengage Servers If you are retrieving a GCM or ADM token by yourself, use this method to send obtained token to Accengage Servers As soon as a valid token has been sended, you will be able to Push from Accengage interface

Parameters
token token returned from GCM or ADM registration process

public static void setDoNotTrackEnabled (Context context, boolean enabled)

public abstract void setGCMEnabled (boolean enabled)

public abstract void setInAppClickedCallback (Callback<InApp> inAppClickedCallback, int... layout)

Set a callback to be called when an in-app (banner) is clicked
Please note that any call to this method will replace any previous call

You should call this method just before calling A4S.get(this).startActivity() or super.onCreate() or you can lock in-app display using setInAppDisplayLocked, call this method and finally unlock in-app display.

Parameters
layout If defined : layout(s) id(s) (example : R.layout.com_ad4screen_banner) to listen to
(callback will be called only if an in-app is clicked into these templates)
Default : callback is called for all templates including overlay (R.layout.com_ad4screen_sdk_overlay)

public abstract void setInAppClosedCallback (Callback<InApp> inAppClosedCallback, int... layout)

Set a callback to be called when an in-app (banner) is displayed
Please note that any call to this method will replace any previous call

You should call this method just before calling A4S.get(this).startActivity() or super.onCreate() or you can lock in-app display using setInAppDisplayLocked, call this method and finally unlock in-app display.

Parameters
layout If defined : layout(s) id(s) (example : R.layout.com_ad4screen_banner) to listen to
(callback will be called only if an in-app is displayed into these templates)
Default : callback is called for all templates including overlay (R.layout.com_ad4screen_sdk_overlay)

public abstract void setInAppDisplayLocked (boolean locked)

Allows you to allow or prevent InApp visual elements to be displayed. Default is false (display is enabled).
Warning Once Inapp is locked, no InApp visual element will be displayed anymore until unlocked, use with care!

Parameters
locked True if you want to prevent any inapp display to be displayed anymore, false to unlock and allow display again.
See Also
  • #getInAppDisplayLocked

public abstract void setInAppDisplayedCallback (Callback<InApp> inAppDisplayedCallback, int... layout)

Set a callback to be called when an in-app (banner) is closed
Please note that any call to this method will replace any previous call

You should call this method just before calling A4S.get(this).startActivity() or super.onCreate() or you can lock in-app display using setInAppDisplayLocked, call this method and finally unlock in-app display.

Parameters
layout If defined : layout(s) id(s) (example : R.layout.com_ad4screen_banner) to listen to
(callback will be called only if an in-app is closed into these templates)
Default : callback is called for all templates including overlay (R.layout.com_ad4screen_sdk_overlay)

public abstract void setInAppReadyCallback (boolean manuallyAllowDisplay, Callback<InApp> inAppReadyCallback, int... layout)

Set a callback to be called when an in-app (banner) is ready to be displayed
Please note that any call to this method will replace any previous call

Optionally : you can ask the SDK to not display any in-app by setting manuallyAllowDisplay to true
In this case, you will have to call displayInApp(template) in order to display a ready in-app in a template

You should call this method just before calling A4S.get(this).startActivity() or super.onCreate() or you can lock in-app display using setInAppDisplayLocked, call this method and finally unlock in-app display.

Parameters
manuallyAllowDisplay if true, SDK will wait for you to call displayInApp(template) to display an in-app
inAppReadyCallback Callback to call when an in-app is ready to be displayed in an included template
layout If defined : layout(s) id(s) (example : R.layout.com_ad4screen_banner) to listen to
(callback will be called only if an in-app can be displayed into these templates)
Default : callback is called for all templates including overlay (R.layout.com_ad4screen_sdk_overlay)

public abstract void setIntent (Intent intent)

Function to be called by client application when onNewIntent method is called in your Activity Lifecycle

Parameters
intent onNewIntent intent parameter

public abstract void setOverlayPosition (FrameLayout.LayoutParams layoutParams)

Set overlay position for displayed in-app using overlay
This position will never change until you call this method again specifying new position
Default : FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM)
You can use : Gravity.TOP, Gravity.CENTER or Gravity.BOTTOM

Parameters
layoutParams a FrameLayout.LayoutParams specifying width, height and gravity

public abstract void setPushEnabled (boolean enabled)

Enables or disables Push notifications for this device. Note even when enabled, the push may not work on the device due to GCM/ADM restrictions (Android version, Play store presence with Google Account connected, connectivity, ...)
Warning User will not be able to receive push notification while disabled. Use with care!

Parameters
enabled True to enable push and try to register to GCM or ADM. False to unregister from GCM or ADM.

public abstract void setPushNotificationLocked (boolean locked)

Allows you to allow or prevent Landing Page of Push Notifications to be displayed. Default is false : Landing Pages of Rich Push will be displayed as soon as the app opens. For instance : You can lock push on your splashscreen and unlock it as soon as your main activity is displayed This will allow you to launch the clicked push only after your app is fully loaded
Warning Once Push is locked, no Landing Page will be displayed anymore until unlocked, use with care! The last clicked push will be launched as soon as you unlock push notifications.

public abstract void setRestrictedConnection (boolean restricted)

Allows or disallows SDK to use Internet Connection.
You can use it in order to temporarily disable request dispatch from SDK
This can be useful if you need to do some important requests in your app and you don't want the SDK to use the bandwidth for a short amount of time

Please don't forget to setRestrictedConnection(false) or the user will never be tracked again for this session

Parameters
restricted , if true SDK will stop dispatching request to Accengage servers

public abstract void setView (String viewName)

Set the name of the view which is currently displayed to user You can use this to override a Tag annotation (when you are using FragmentActivity with multiple views for instance)

Parameters
viewName The name of the new view displayed

public abstract void startActivity (Activity activity)

Function to be called by client application when any activity is resumed

Parameters
activity resumed activity

public abstract void stopActivity (Activity activity)

Function to be called by client application when any activity is paused

Parameters
activity paused activity

public abstract void subscribeToLists (StaticList... staticLists)

Allow you to subscribe the device user to a list

Parameters
staticLists One or more Static Lists to subscribe to

public abstract void subscribeToLists (List<StaticList> staticLists)

Allow you to subscribe the device user to a list

Parameters
staticLists List of Static Lists to subscribe to

public abstract void trackAddToCart (Cart cart)

Send an item to add to a given cart to Ad4screen Servers

Parameters
cart Cart Object to send

public abstract void trackEvent (long eventId, String... eventArgs)

Sends an event with its accompanying information to Ad4Screen servers.

Parameters
eventId Identifier for the event type. Use any number between 1000 and 5000 by convention.
eventArgs Zero or more string parameters accompanying the event, used to back up business data on the server.

public abstract void trackLead (Lead lead)

Send a lead to Ad4Screen Servers

Parameters
lead Lead Object to send

public abstract void trackPurchase (Purchase purchase)

Send a purchase with or without items to Ad4Screen Servers

Parameters
purchase Purchase Object to send

public abstract void unsubscribeFromLists (List<StaticList> staticLists)

Allow you to cancel the device user subscription

Parameters
staticLists List of Static Lists to unsubscribe from

public abstract void unsubscribeFromLists (StaticList... staticLists)

Allow you to cancel the device user subscription to a list

Parameters
staticLists One or more Static Lists to unsubscribe from

public abstract void updateDeviceInfo (Bundle bundle)

Send user data to Accengage servers to update this device information.
Warning Only use this function if you have a segmentation plan. Ask your contact for more information about segmentation and data formating
Note The keys and values must match Accengage user information fields names and value to allow information to be correctly updated.

Parameters
bundle Bag of key/values pairs to be sent to Accengage to allow user segmentation.

public abstract void updateGeolocation (Location location)

Send a new Geolocation to Accengage Servers Use this method if you are using no-geoloc meta-data and you need to manually update geolocation of this device Please note that you can send a new Geolocation only once by 5 minutes

public abstract void updateMessages (Inbox inbox)

Send an update of read/unread status and archive status for this inbox to Ad4screen Servers

Parameters
inbox inbox to update