com.sponsorpay.sdk.android
Class HostInfo

java.lang.Object
  extended by com.sponsorpay.sdk.android.HostInfo

public class HostInfo
extends java.lang.Object

Extracts device information from the host device in which the SDK runs and SponsorPay App ID contained in the Android Application Manifest of the host app.


Field Summary
private static java.lang.String ANDROID_OS_PREFIX
          Prefix appended to the OS version to identify the Android platform.
private  java.lang.String mAndroidId
          Android ID as reported by Settings.Secure
private  java.lang.String mAppId
          The App ID value.
private  Context mContext
          Android application context, used to retrieve the rest of the properties.
private  java.lang.String mLanguageSetting
          Language settings (the default locale).
private  java.lang.String mOsVersion
          The running Android OS version (e.g.
private  java.lang.String mPhoneVersion
          The device version (e.g.
private  java.lang.String mUDID
          The unique device ID.
private  java.lang.String mWifiMacAddress
          MAC Address of the WiFi Adapter
private static java.lang.String SPONSORPAY_APP_ID_KEY
          The Sponsorpay App ID Key that is used in the AndroidManifest.xml file.
 
Constructor Summary
HostInfo(Context context)
          Constructor.
 
Method Summary
 java.lang.String getAndroidId()
          Returns the device's Android ID.
 java.lang.String getAppId()
           Extracts the App ID from the host application's Android Manifest XML file.
 java.lang.String getLanguageSetting()
          Get the default locale set by the user
 java.lang.String getOsVersion()
          Get the running OS version
 java.lang.String getPhoneVersion()
          Get the current phone model
 java.lang.String getUDID()
          Get the unique device ID
private  java.lang.String getValueFromAppMetadata(java.lang.String key)
          Extracts numeric or alphanumeric value from the meta-data configured in the application manifest XML file and returns it as a String.
 java.lang.String getWifiMacAddress()
          Returns the MAC address of the device's WiFi adapter.
 void setOverriddenAppId(java.lang.String appId)
          Set the offerId, overriding the one which would be read from the manifest.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANDROID_OS_PREFIX

private static final java.lang.String ANDROID_OS_PREFIX
Prefix appended to the OS version to identify the Android platform.

See Also:
Constant Field Values

mUDID

private java.lang.String mUDID
The unique device ID.


mOsVersion

private java.lang.String mOsVersion
The running Android OS version (e.g. "2.1" for Android 2.1).


mPhoneVersion

private java.lang.String mPhoneVersion
The device version (e.g. "HTC Nexus One").


mLanguageSetting

private java.lang.String mLanguageSetting
Language settings (the default locale).


mAndroidId

private java.lang.String mAndroidId
Android ID as reported by Settings.Secure


mWifiMacAddress

private java.lang.String mWifiMacAddress
MAC Address of the WiFi Adapter


SPONSORPAY_APP_ID_KEY

private static final java.lang.String SPONSORPAY_APP_ID_KEY
The Sponsorpay App ID Key that is used in the AndroidManifest.xml file.

See Also:
Constant Field Values

mAppId

private java.lang.String mAppId
The App ID value.


mContext

private Context mContext
Android application context, used to retrieve the rest of the properties.

Constructor Detail

HostInfo

public HostInfo(Context context)
Constructor. Requires an Android application context which will be used to retrieve information from the device and the host application's Android Manifest.

Parameters:
context - Android application context
Method Detail

getUDID

public java.lang.String getUDID()
Get the unique device ID

Returns:
the unique device id

getOsVersion

public java.lang.String getOsVersion()
Get the running OS version

Returns:
the OS version

getPhoneVersion

public java.lang.String getPhoneVersion()
Get the current phone model

Returns:
the phone model

getLanguageSetting

public java.lang.String getLanguageSetting()
Get the default locale set by the user

Returns:
the default language setting

getAndroidId

public java.lang.String getAndroidId()
Returns the device's Android ID.


getWifiMacAddress

public java.lang.String getWifiMacAddress()
Returns the MAC address of the device's WiFi adapter.


getValueFromAppMetadata

private java.lang.String getValueFromAppMetadata(java.lang.String key)
Extracts numeric or alphanumeric value from the meta-data configured in the application manifest XML file and returns it as a String.

Parameters:
key - key to identify the piece of meta-data to return.
Returns:
the value for the given key, or null on failure.

getAppId

public java.lang.String getAppId()

Extracts the App ID from the host application's Android Manifest XML file.

If the App Id has already been set (i.e. by calling the setOverriddenAppId(String)), this method will just return the id which has been set without trying to retrieve it from the manifest.

If no App ID is present in the manifest and no non-empty App ID has been set by calling the mentioned method, this method will throw a RuntimeException.

Returns:
The offer id previously set or defined in the manifest, or 0.

setOverriddenAppId

public void setOverriddenAppId(java.lang.String appId)
Set the offerId, overriding the one which would be read from the manifest.

Parameters:
offerId -