public class Tune extends Object
Modifier and Type | Field and Description |
---|---|
protected TuneEventQueue |
eventQueue |
protected boolean |
initialized |
protected boolean |
isRegistered |
protected Context |
mContext |
protected BroadcastReceiver |
networkStateReceiver |
protected TuneParameters |
params |
protected ExecutorService |
pubQueue |
protected TuneTestRequest |
tuneRequest |
Modifier | Constructor and Description |
---|---|
protected |
Tune() |
Modifier and Type | Method and Description |
---|---|
protected void |
addEventToQueue(String link,
String data,
JSONObject postBody,
boolean firstSession) |
protected void |
dumpQueue() |
String |
getAction()
Gets the action of the event
|
String |
getAdvertiserId()
Gets the MAT advertiser ID.
|
double |
getAltitude()
Gets the device altitude.
|
String |
getAndroidId()
Gets the ANDROID_ID of the device
|
boolean |
getAppAdTrackingEnabled()
Get whether the user has app-level ad tracking enabled or not.
|
String |
getAppName()
Gets the app name
|
int |
getAppVersion()
Gets the app version
|
String |
getConnectionType()
Gets the connection type (mobile or WIFI);.
|
String |
getCountryCode()
Gets the ISO 639-1 country code
|
String |
getCurrencyCode()
Gets the ISO 4217 currency code.
|
String |
getDeviceBrand()
Gets the device brand/manufacturer (HTC, Apple, etc)
|
String |
getDeviceCarrier()
Gets the device carrier if any
|
String |
getDeviceId()
Gets the Device ID, also known as IMEI/MEID, if any
|
String |
getDeviceModel()
Gets the device model name
|
boolean |
getGoogleAdTrackingLimited()
Gets whether use of the Google Play Services Advertising ID is limited by user request.
|
String |
getGoogleAdvertisingId()
Gets the Google Play Services Advertising ID.
|
long |
getInstallDate()
Gets the date of app install
|
String |
getInstallReferrer()
Gets the Google Play INSTALL_REFERRER
|
static Tune |
getInstance()
Get existing TUNE singleton object
|
String |
getLanguage()
Gets the language of the device
|
String |
getLastOpenLogId()
Gets the last MAT open log ID
|
double |
getLatitude()
Gets the device latitude.
|
double |
getLongitude()
Gets the device longitude.
|
String |
getMacAddress()
Gets the MAC address of device
|
String |
getMatId()
Gets the MAT ID generated on install
|
String |
getMCC()
Gets the mobile country code.
|
String |
getMNC()
Gets the mobile network code.
|
String |
getOpenLogId()
Gets the first MAT open log ID
|
String |
getOsVersion()
Gets the Android OS version
|
String |
getPackageName()
Gets the app package name
|
String |
getPluginName()
Get SDK plugin name used
|
String |
getReferralSource()
Gets the package name of the app that started this Activity, if any
|
String |
getReferralUrl()
Gets the url scheme that started this Activity, if any
|
String |
getRefId()
Gets the advertiser ref ID.
|
Double |
getRevenue()
Gets the revenue amount set
|
String |
getScreenDensity()
Gets the screen density of the device
|
String |
getScreenHeight()
Gets the screen height of the device in pixels
|
String |
getScreenWidth()
Gets the screen width of the device in pixels
|
String |
getSDKVersion()
Gets the TUNE SDK version
|
String |
getSiteId()
Gets the MAT site ID set
|
String |
getTRUSTeId()
Gets the TRUSTe ID set
|
TuneUser |
getUser() |
String |
getUserAgent()
Gets the device browser user agent
|
static Tune |
init(Context context,
String advertiserId,
String conversionKey)
Initializes the TUNE SDK.
|
protected void |
initAll(String advertiserId,
String conversionKey)
Private initialization function for TUNE SDK.
|
static boolean |
isOnline(Context context)
Returns true if an Internet connection is detected.
|
protected boolean |
makeRequest(String link,
String data,
JSONObject postBody)
Helper function for making single request and displaying response
|
void |
measureEvent(int eventId)
Event measurement function that measures an event for the given eventId.
|
void |
measureEvent(String eventName)
Event measurement function that measures an event for the given eventName.
|
void |
measureEvent(TuneEvent eventData)
Event measurement function that measures an event based on MatEvent values.
|
void |
measureSession()
Main session measurement function; this function should be called in onResume().
|
void |
setAdvertiserId(String advertiserId)
Sets the MAT advertiser ID
|
void |
setAllowDuplicates(boolean allow)
Enables acceptance of duplicate installs from this device.
|
void |
setAltitude(double altitude)
Sets the device altitude.
|
void |
setAndroidId(String androidId)
Sets the ANDROID ID
|
void |
setAndroidIdMd5(String androidIdMd5)
Sets the ANDROID ID MD5 hash
|
void |
setAndroidIdSha1(String androidIdSha1)
Sets the ANDROID ID SHA-1 hash
|
void |
setAndroidIdSha256(String androidIdSha256)
Sets the ANDROID ID SHA-256 hash
|
void |
setAppAdTrackingEnabled(boolean adTrackingEnabled)
Sets whether app-level ad tracking is enabled.
|
void |
setConversionKey(String conversionKey)
Sets the conversion key for the SDK
|
void |
setCurrencyCode(String currency_code)
Sets the ISO 4217 currency code.
|
void |
setDebugMode(boolean debug)
Turns debug mode on or off, under tag "TUNE".
|
void |
setDeferredDeeplink(boolean enableDeferredDeeplink,
int timeout)
Enables or disables opening deferred deeplinks
|
void |
setDeviceId(String deviceId)
Sets the device IMEI/MEID
|
void |
setEmailCollection(boolean collectEmail)
Enables or disables primary Gmail address collection
Requires GET_ACCOUNTS permission
|
void |
setFacebookEventLogging(boolean logging,
Context context,
boolean limitEventAndDataUsage)
Whether to log TUNE events in the FB SDK as well
|
void |
setGoogleAdvertisingId(String adId,
boolean isLATEnabled)
Sets the Google Play Services Advertising ID
|
void |
setInstallReferrer(String referrer)
Overrides the Google Play INSTALL_REFERRER received
|
void |
setLatitude(double latitude)
Sets the device latitude.
|
void |
setListener(TuneListener listener)
Register a TuneListener interface to receive server response callback
|
void |
setLocation(Location location) |
void |
setLongitude(double longitude)
Sets the device longitude.
|
void |
setMacAddress(String macAddress)
Sets the device MAC address.
|
void |
setPackageName(String packageName)
Sets the app package name
|
void |
setPhoneNumber(String phoneNumber)
Sets the device phone number
|
void |
setPluginName(String plugin_name)
Set the name of plugin used, if any
|
void |
setPreloadedApp(TunePreloadData preloadData)
Sets publisher information for device preloaded apps
|
void |
setReferralSources(Activity act)
Get referral sources from Activity
|
void |
setSiteId(String siteId)
Sets the MAT site ID to specify which app to attribute to
|
void |
setTRUSTeId(String tpid)
Sets the TRUSTe ID, should generate via their SDK
|
void |
setUser(TuneUser user) |
Tune |
withAllowDuplicates(boolean allowDups)
Enables SDK instance with acceptance of duplicate installs from this device
|
Tune |
withDebugMode(boolean debugMode)
Enables SDK instance with debug output under tag "TUNE"
|
Tune |
withDeferredDeeplink(boolean enableDeferredDeeplink,
int timeout)
Enables SDK instance with deferred deeplinks
|
Tune |
withEmailCollection(boolean collectEmail)
Enables SDK instance with primary Gmail collection
Requires GET_ACCOUNTS permission
|
Tune |
withFacebookEventLogging(boolean logging,
Context context,
boolean limitEventAndDataUsage)
Enables SDK instance with Facebook event logging, passing TUNE events to FB
|
Tune |
withListener(TuneListener response)
Enables SDK instance with a server response listener
|
Tune |
withPackageName(String packageName)
Enables SDK instance with a custom package name
|
Tune |
withSiteId(String siteId)
Enables SDK instance with a custom site ID
|
protected BroadcastReceiver networkStateReceiver
protected Context mContext
protected ExecutorService pubQueue
protected TuneEventQueue eventQueue
protected TuneParameters params
protected TuneTestRequest tuneRequest
protected boolean initialized
protected boolean isRegistered
public static Tune getInstance()
public Tune withAllowDuplicates(boolean allowDups)
allowDups
- whether to allow duplicate installs from devicepublic Tune withDebugMode(boolean debugMode)
debugMode
- whether to enable debug outputpublic Tune withDeferredDeeplink(boolean enableDeferredDeeplink, int timeout)
enableDeferredDeeplink
- whether to enable opening deferred deeplinkstimeout
- max timeout in ms to wait for deeplinkpublic Tune withEmailCollection(boolean collectEmail)
collectEmail
- whether to collect device email addresspublic Tune withFacebookEventLogging(boolean logging, Context context, boolean limitEventAndDataUsage)
logging
- whether to enable FB loggingcontext
- Activity contextlimitEventAndDataUsage
- whether FB event logging is limited for ad targetingpublic Tune withListener(TuneListener response)
response
- listener for server responsepublic Tune withPackageName(String packageName)
packageName
- custom package name to passpublic Tune withSiteId(String siteId)
siteId
- custom site ID to passpublic static Tune init(Context context, String advertiserId, String conversionKey)
context
- the application contextadvertiserId
- the TUNE advertiser ID for the appconversionKey
- the TUNE advertiser key for the appprotected void initAll(String advertiserId, String conversionKey)
advertiserId
- the TUNE advertiser ID for the appconversionKey
- the TUNE conversion key for the apppublic static boolean isOnline(Context context)
context
- the app context to check connectivity fromprotected void addEventToQueue(String link, String data, JSONObject postBody, boolean firstSession)
protected void dumpQueue()
public void measureSession()
public void measureEvent(String eventName)
eventName
- event name in MAT systempublic void measureEvent(int eventId)
eventId
- event ID in MAT systempublic void measureEvent(TuneEvent eventData)
new MatEvent(eventName)
eventData
- custom data to associate with the eventprotected boolean makeRequest(String link, String data, JSONObject postBody)
public String getAction()
public String getAdvertiserId()
public double getAltitude()
public String getAndroidId()
public boolean getAppAdTrackingEnabled()
public String getAppName()
public int getAppVersion()
public String getConnectionType()
public String getCountryCode()
public String getCurrencyCode()
public String getDeviceBrand()
public String getDeviceCarrier()
public String getDeviceId()
public String getDeviceModel()
public String getGoogleAdvertisingId()
public boolean getGoogleAdTrackingLimited()
public long getInstallDate()
public String getInstallReferrer()
public String getLanguage()
public String getLastOpenLogId()
public double getLatitude()
public double getLongitude()
public String getMacAddress()
public String getMatId()
public String getMCC()
public String getMNC()
public String getOpenLogId()
public String getOsVersion()
public String getPackageName()
public String getPluginName()
public String getReferralSource()
public String getReferralUrl()
public String getRefId()
public Double getRevenue()
public String getScreenDensity()
public String getScreenHeight()
public String getScreenWidth()
public String getSDKVersion()
public String getSiteId()
public String getTRUSTeId()
public TuneUser getUser()
public String getUserAgent()
public void setAdvertiserId(String advertiserId)
advertiserId
- MAT advertiser IDpublic void setAltitude(double altitude)
altitude
- device altitudepublic void setAndroidId(String androidId)
androidId
- ANDROID_IDpublic void setAndroidIdMd5(String androidIdMd5)
androidIdMd5
- ANDROID_ID MD5 hashpublic void setAndroidIdSha1(String androidIdSha1)
androidIdSha1
- ANDROID_ID SHA-1 hashpublic void setAndroidIdSha256(String androidIdSha256)
androidIdSha256
- ANDROID_ID SHA-256 hashpublic void setAppAdTrackingEnabled(boolean adTrackingEnabled)
adTrackingEnabled
- true if user has opted out of ad tracking at the app-level, false if notpublic void setConversionKey(String conversionKey)
conversionKey
- MAT conversion keypublic void setCurrencyCode(String currency_code)
currency_code
- the currency codepublic void setDeviceId(String deviceId)
deviceId
- device IMEI/MEIDpublic void setGoogleAdvertisingId(String adId, boolean isLATEnabled)
adId
- Google Play advertising IDisLATEnabled
- whether user has requested to limit use of the Google ad IDpublic void setInstallReferrer(String referrer)
referrer
- Your custom referrer valuepublic void setLatitude(double latitude)
latitude
- the device latitudepublic void setLocation(Location location)
public void setLongitude(double longitude)
longitude
- the device longitudepublic void setMacAddress(String macAddress)
macAddress
- device MAC addresspublic void setListener(TuneListener listener)
listener
- a TuneListener object that will be called when server request is completepublic void setPackageName(String packageName)
packageName
- App package namepublic void setPhoneNumber(String phoneNumber)
phoneNumber
- Phone numberpublic void setPreloadedApp(TunePreloadData preloadData)
preloadData
- Preload app attribution datapublic void setReferralSources(Activity act)
act
- Activity to get referring package name and url scheme frompublic void setSiteId(String siteId)
siteId
- MAT site ID to attribute topublic void setTRUSTeId(String tpid)
tpid
- TRUSTe IDpublic void setUser(TuneUser user)
public void setPluginName(String plugin_name)
plugin_name
- public void setAllowDuplicates(boolean allow)
allow
- whether to allow duplicate installs from devicepublic void setDebugMode(boolean debug)
debug
- whether to enable debug outputpublic void setDeferredDeeplink(boolean enableDeferredDeeplink, int timeout)
enableDeferredDeeplink
- whether to open deferred deeplinkstimeout
- maximum timeout to wait for deeplink in mspublic void setEmailCollection(boolean collectEmail)
collectEmail
- whether to collect device email addresspublic void setFacebookEventLogging(boolean logging, Context context, boolean limitEventAndDataUsage)
logging
- Whether to send TUNE events to FB as wellcontext
- Activity contextlimitEventAndDataUsage
- Whether user opted out of ads targeting