com.sponsorpay.sdk.android.advertiser
Class SponsorPayAdvertiser

java.lang.Object
  extended by com.sponsorpay.sdk.android.advertiser.SponsorPayAdvertiser
All Implemented Interfaces:
AdvertiserCallbackSender.APIResultListener

public class SponsorPayAdvertiser
extends java.lang.Object
implements AdvertiserCallbackSender.APIResultListener

Provides convenience calls to run the Advertiser callback request. Manages the state of the SDK determining whether a successful response to the callback request has been already received since the application was installed in the host device.

It's implemented as a singleton, and its public methods are static.


Field Summary
private  AdvertiserCallbackSender mAPICaller
          AdvertiserCallbackSender used to call the Advertiser API asynchronously.
private  Context mContext
          Host app's Android application context.
private  HostInfo mHostInfo
          AdvertiserHostInfo used to collect data related to the host device and application.
private static SponsorPayAdvertiser mInstance
          Singleton instance.
private  SharedPreferences mPrefs
          The shared preferences encoded in the PREFERENCES_FILE_NAME file.
private static java.lang.String PREFERENCES_FILE_NAME
          Shared preferences file name.
private static boolean sShouldUseStagingUrls
           
private static java.lang.String STATE_GOT_SUCCESSFUL_RESPONSE_KEY
          The key to store in the preferences file the flag which determines if we have already successfully contacted the Advertiser API.
 
Constructor Summary
private SponsorPayAdvertiser(Context context)
          Constructor.
 
Method Summary
 void onAPIResponse(boolean wasSuccessful)
          This method is invoked when a response for the advertiser callback is received.
private  void register()
          Calls its overload register() with an empty overrideAppId parameter.
static void register(Context context)
          Trigger the Advertiser callback.
static void register(Context context, java.lang.String overrideAppId)
          Trigger the Advertiser callback.
static void registerWithDelay(Context context, int delayMin)
          Trigger the Advertiser callback after the specified delay has passed.
static void registerWithDelay(Context context, int delayMin, java.lang.String overrideAppId)
          Trigger the Advertiser callback after the specified delay has passed.
static void setShouldUseStagingUrls(boolean value)
           
static boolean shouldUseStagingUrls()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFERENCES_FILE_NAME

private static final java.lang.String PREFERENCES_FILE_NAME
Shared preferences file name. We store a flag into the shared preferences which is checked on each consecutive invocation of register(), to keep track of whether we have already successfully contacted the Advertiser API.

See Also:
Constant Field Values

STATE_GOT_SUCCESSFUL_RESPONSE_KEY

private static final java.lang.String STATE_GOT_SUCCESSFUL_RESPONSE_KEY
The key to store in the preferences file the flag which determines if we have already successfully contacted the Advertiser API.

See Also:
Constant Field Values

mPrefs

private SharedPreferences mPrefs
The shared preferences encoded in the PREFERENCES_FILE_NAME file.


sShouldUseStagingUrls

private static boolean sShouldUseStagingUrls

mHostInfo

private HostInfo mHostInfo
AdvertiserHostInfo used to collect data related to the host device and application.


mAPICaller

private AdvertiserCallbackSender mAPICaller
AdvertiserCallbackSender used to call the Advertiser API asynchronously.


mContext

private Context mContext
Host app's Android application context.


mInstance

private static SponsorPayAdvertiser mInstance
Singleton instance.

Constructor Detail

SponsorPayAdvertiser

private SponsorPayAdvertiser(Context context)
Constructor. Stores the received application context and loads up the shared preferences.

Parameters:
context - The host application context.
Method Detail

setShouldUseStagingUrls

public static void setShouldUseStagingUrls(boolean value)

shouldUseStagingUrls

public static boolean shouldUseStagingUrls()

register

public static void register(Context context)
Trigger the Advertiser callback. Will try to retrieve the Application ID from the value defined in the host application's Android Manifest XML file.

Parameters:
context - Host application context.

registerWithDelay

public static void registerWithDelay(Context context,
                                     int delayMin)
Trigger the Advertiser callback after the specified delay has passed. Will retrieve the App ID from the value defined in the host application's Android Manifest XML file.

Parameters:
context - Host application context.
delayMin - The delay in minutes for triggering the Advertiser callback.

registerWithDelay

public static void registerWithDelay(Context context,
                                     int delayMin,
                                     java.lang.String overrideAppId)
Trigger the Advertiser callback after the specified delay has passed. Will use the provided App ID instead of trying to retrieve the one defined in the host application's manifest.

Parameters:
context - Host application context.
delayMin - The delay in minutes for triggering the Advertiser callback.
overrideAppId - The App ID to use.

register

public static void register(Context context,
                            java.lang.String overrideAppId)
Trigger the Advertiser callback. If passed a non-null and non-empty Application ID, it will be used. Otherwise the Application ID will be retrieved from the value defined in the host application's Android Manifest XML file.

Parameters:
context - Host application context.
overrideAppId - The App ID to use.

register

private void register()
Calls its overload register() with an empty overrideAppId parameter.


onAPIResponse

public void onAPIResponse(boolean wasSuccessful)
This method is invoked when a response for the advertiser callback is received.

Specified by:
onAPIResponse in interface AdvertiserCallbackSender.APIResultListener
Parameters:
wasSuccessful - status flag if the Advertiser API has been contacted successfully