Sei sulla pagina 1di 25

YahooAppPublishing

AndroidSDKInstructions

SDKversion6.2.0
Updated:11/09/2015

Welcometo
YahooAppPublishing
!

ThisREADMEcontains:

1.Introduction
2.BasicIntegration
3.Nativeadobjectlifecycle
4.AdditionalAdControls(Optional)
5
.
EnablingAdNetworkMediation(Optional)
6.AdTargetingOptions(Optional)
7.TumblrInAppSharing
8.UsingProGuard(Optional)

1.Introduction

YahooAppPublishingisaflexibleadservingsolutionthatallowsyoutoeasilymanagethecomplete
monetizationofyourmobileapplications.ThroughintegrationwithFlurryAnalyticsandvariousmobilead
networks,publisherscaneasilygeneratethemaximumvaluefromadcampaigns.BothFFA(FlurryFor
Advertisers)andFFP(FlurryForPublishersdirectandcustomnetwork)adcampaignsarecreatedand
managedinthesameinterface.

WithFFPyouwillbeableto:
1. Defineyourinventory
2. Trafficyouradcampaigns
3. Track&optimizeyourperformance

TheFlurrySDKcontainsalltheexistingFlurryAnalyticsfunctionalityaswellasthenewAdvertising
functionality.Itisdesignedtobeaseasyaspossiblewithabasicsetupcompletedinunder5minutes.

TheseinstructionsassumethatyouhavealreadyintegratedFlurryAnalyticsintoyourapplication.Ifyouhave
notdoneso,pleasereferto
AnalyticsREADME
togetstarted.

ForadspacesetupandmoreinformationonYahooAppPublishing,pleasevisit
https://developer.yahoo.com/flurry/docs/publisher/

Pleasenote,itis
required
thatyoucreateadspacesbeforeretrievingads.Adspacescanbecreatedonthe
FlurryDeveloperPortalorintheapplicationcode.If
Adspacesarecreatedinthecode,theywillappearinthe
devportaldesignatedasDeterminedbySDKintheAdspacesetuppage.

YahooAppPublishingusestheAndroidAdvertisingIDprovidedbyGooglePlayServicesandwill
checkfor
andrespecttheuser'sadtrackingpreference
.Formoreinformation,pleasevisit
https://developer.android.com/google/playservices/id.html

2.BasicIntegration

FlurryAdsrequiresminimumAndroidAPIlevel10.
TointegrateYahooAppPublishingintoyourAndroid
application,justcompletetwosteps:

Step1.Includetheappropriatejar
FlurryAdsworkontopofFlurryanalytics.AddFlurryAds_6.2.0.jarfile(inadditiontothethe
FlurryAnalytics_6.2.0.jarand)toyourclasspath.

UsingAndroidStudio:
1. AddFlurryAnalytics
_6.2.0.jarandFlurryAds_6.2.0.jartoyourproject'slibsfolder.
2. NavigatetoFile>ProjectStructure>Module>Dependencies.Clickthe+buttoninthebottomof
theProjectStructurepopuptoadddependencies.SelectFiledependencyandadd
libs/FlurryAnalytics_
6.2.0.jarandlibs/FlurryAds_6.2.0.jarand.
3. AddGooglePlayServiceslibrary.Pleasefollowinstructionsat
http://developer.android.com/google/playservices/setup.html#Setup
4. Addv4supportlibrary(orgreater).Pleasefollowinstructionsat
https://developer.android.com/tools/supportlibrary/setup.html#addlibrary

UsingEclipse:
1. AddFlurryAnalytics
_6.2.0.jarandFlurryAds_6.2.0.jartoyourprojectslibsfolder.Rightclickoneach
JARfileandselectBuildPath>AddtoBuildPath.
2. AddGooglePlayServicelibrary.Pleasefollowinstructionsat
http://developer.android.com/google/playservices/setup.html#Setup
3. Addv4SupportLibrary(orgreater).Pleasefollowinstructionsat
https://developer.android.com/tools/supportlibrary/setup.html#addlibrary
.

Step2.DeclareourActivityinyourmanifest
DeclaretheActivityFlurryFullscreenTakeoverActivityinyourAndroidManifest.xmlfile:
<activity
android:name="com.flurry.android.FlurryFullscreenTakeoverActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|ui
Mode|screenSize|smallestScreenSize"
</activity>

Thisisrequiredtoshowinterstitialads.

OptionalPermission

(HighlyRecommended):
android.permission.WRITE_EXTERNAL_STORAGE

Externalstorageisusedforprecachingfeaturesifavailable.

Step3.RequestinganAd

3.1BannerAd
Inordertoservebanneradspleaseuse
FlurryAdBanner
and
FlurryAdBannerListener
:

publicclassExampleextendsActivity{
privateRelativeLayoutmBanner
privateFlurryAdBannermFlurryAdBanner=null
privateStringmAdSpaceName=BANNER_ADSPACE_NAME

publicvoidonCreate(Bundlebundle){
super.onCreate(bundle)
setContentView(R.layout.example)
mBanner=(RelativeLayout)findViewById(R.id.banner)
mFlurryAdBanner=newFlurryAdBanner(this,mBanner,mAdSpaceName)

//allowustogetcallbacksforadevents
mFlurryAdBanner.setListener(bannerAdListener)
}
publicvoidonStart(){
super.onStart()
FlurryAgent.onStartSession(this)
//fetchandprepareadforthisadspace.wontrenderoneyet
mFlurryAdBanner.fetchAd()
}
publicvoidonStop(){
super.onStop()
FlurryAgent.onEndSession(this)
mFlurryAdBanner.destroy()
}

FlurryAdBannerListenerbannerAdListener=newFlurryAdBannerListener(){

@Override

publicvoidonFetched(FlurryAdBanneradBanner){
adBanner.displayAd()
}

@Override

publicvoidonError(FlurryAdBanneradBanner,FlurryAdErrorType
adErrorType,interrorCode){
adBanner.destroy()

}
@Override
publicvoidonRendered(FlurryAdBanneradBanner){}
@Override
publicvoidonShowFullscreen(FlurryAdBanneradBanner){}
@Override
publicvoidonCloseFullscreen(FlurryAdBanneradBanner){}
@Override
publicvoidonAppExit(FlurryAdBanneradBanner){}
@Override
publicvoidonClicked(FlurryAdBanneradBanner){}

@Override
publicvoidonVideoCompleted(FlurryAdBanneradBanner){}
}

ImplementingFlurryAdBannerListener
TobenotifiedofcertaineventsduringthefulllifecycleoftheAd,youshallimplementthe
FlurryAdBannerListener
interfaceandthencallthesetListenermethodtoattachyourimplementationof
FlurryAdBannerListener
totheFlurrySDK.Youwillneedtoimplementthefollowingcallbackmethods:

onClicked(FlurryAdBanneradBanner)
Thismethodwillbecalledwhentheuserhasclickedonthead.
onCloseFullscreen(FlurryAdBanneradBanner)
ThismethodwillbecalledwhentheuserdismissesthecurrentAdfortheprovidedAdSpace
name.
onShowFullscreen(FlurryAdBanneradBanner)
Thismethodwillbecalledwhentheuserhasopenedthead.
onAppExit(FlurryAdBanneradBanner)
Thismethodwillbecalledwhentheuserisleavingtheapplicationafterfollowingevents
associatedwiththecurrentAdintheprovidedAdSpacename.
onRendered(FlurryAdBanneradBanner)
Thismethodwillbecalledwhenadissuccessfullyrendered.
onError(FlurryAdBanneradBanner,FlurryAdErrorTypeadErrorType,int
errorCode)
Thismethodwillbecalledwhenfetch,renderorclickfailed.
onFetched(FlurryAdBanneradBanner)
Thismethodwillbecalledwhentheadhasbeenreceivedfromtheserver

onVideoCompleted(
FlurryAdBanneradBanner
)

ThismethodispresentonlyIncasetheadservedisavideoclipandadspaceismarkedas
clientsiderewarded,orrewarded.

Note:pleasesee
AnalyticsREADME
fordetailson
FlurryAgent.onStartSession()

Herearethedetailsontheparametersto
FlurryAdBanner
:
Contextcontext
WeadviseusingthecurrentActivity.
StringadSpace

UniquenameofyouradplacementdefinedontheFlurrywebsite.
ViewGroupviewSpace

ViewGroupinsidetheContextthatyouwanttheadtoresidein.We
suggestusinga
RelativeLayout
FlurryAdErrorType
adErrorType
Aderrortypes.

Inordertospecifytheformatandsize,pleasevisitFlurrysdeveloperportalat
https://dev.flurry.com/FFPSetupAdSpaces.do

3.2InterstitialAd
Inordertoserveinterstitialadspleaseuse
FlurryAdInterstitial
and
FlurryAdInterstitialListener
:

publicclassExampleextendsActivity{

privateFlurryAdInterstitialmFlurryAdInterstitial=null
privateStringmAdSpaceName=INTERSTITIAL_ADSPACE_NAME

publicvoidonCreate(Bundlebundle){
super.onCreate(bundle)
setContentView(R.layout.example)
mFlurryAdInterstitial=newFlurryAdInterstitial(this,mAdSpaceName)

//allowustogetcallbacksforadevents
mFlurryAdInterstitial.setListener(interstitialAdListener)
}
publicvoidonStart(){
super.onStart()
FlurryAgent.onStartSession(this)
//fetchandprepareadforthisadspace.wontrenderoneyet
mFlurryAdInterstitial.fetchAd()
}
publicvoidonStop(){
super.onStop()
FlurryAgent.onEndSession(this)
mFlurryAdInterstitial.destroy()
}

FlurryAdInterstitialListenerinterstitialAdListener=new
FlurryAdInterstitialListener(){

@Override
publicvoidonFetched(FlurryAdInterstitialadInterstitial){
adInterstitial.displayAd()
}

@Override

publicvoidonError(FlurryAdInterstitialadInterstitial,FlurryAdErrorType
adErrorType,interrorCode){
adInterstitial.destroy()

@Override

publicvoidonRendered(FlurryAdInterstitialadInterstitial){}

@Override

publicvoidonDisplay(FlurryAdInterstitialadInterstitial){}

@Override

publicvoidonClose(FlurryAdInterstitialadInterstitial){}

@Override

publicvoidonAppExit(FlurryAdInterstitialadInterstitial){}

@Override

publicvoidonClicked(FlurryAdInterstitialadInterstitial){}

@Override

publicvoidonVideoCompleted(FlurryAdInterstitialadInterstitial){}
}
}

ImplementingFlurryAdInterstitialListener
TobenotifiedofcertaineventsduringthefulllifecycleoftheAd,youshallimplementthe
FlurryAdInterstitialListener
interfaceandthencallthesetListenermethodtoattachyour
implementationof
FlurryAdInterstitialListener
totheFlurrySDK.Youwillneedtoimplementthe
followingcallbackmethods:

onClicked(FlurryAdInterstitialadInterstitial)
Thismethodwillbecalledwhentheuserhasclickedonthead.
onClose(FlurryAdInterstitialadInterstitial)
ThismethodwillbecalledwhentheuserdismissesthecurrentAdfortheprovidedAdSpace
name.
onDisplay(FlurryAdInterstitialadInterstitial)
Thismethodwillbecalledwhentheuserhasopenedthead.
onAppExit(FlurryAdInterstitialadInterstitial)
Thismethodwillbecalledwhentheuserisleavingtheapplicationafterfollowingevents
associatedwiththecurrentAdintheprovidedAdSpacename.
onRendered(FlurryAdInterstitialadInterstitial)

Thismethodwillbecalledwhenadissuccessfullyrendered.
onError(FlurryAdInterstitialadInterstitial,FlurryAdErrorType
adErrorType,interrorCode)
Thismethodwillbecalledwhenfetch,renderorclickfailed.Therecanbemanyreasonsfor
thefailure.
onFetched(FlurryAdInterstitialadInterstitial)
Thismethodwillbecalledwhentheadhasbeenreceivedfromtheserver

onVideoCompleted(
FlurryAdInterstitialadInterstitial
)

Incasetheadservedisavideoclipandadspaceismarkedasclientsiderewarded,this
method

Note:pleasesee
AnalyticsREADME
fordetailson
FlurryAgent.onStartSession()

Herearethedetailsontheparametersto
fetchAd
and
displayAd
:
Contextcontext
WeadviseusingthecurrentActivity.
StringadSpace

Uniquenameofyouradplacement,maydefinedontheFlurrywebsite,but
doesnothavetobe
FlurryAdErrorType
adErrorType
Aderrortypes.

3.3NativeAd

3.3.1NativeImageAd
Inordertoservenativeadsuse
FlurryAdNative
and
FlurryAdNativeListener
:

publicclassExampleextendsActivity{
privateFlurryAdNativemFlurryAdNative=null
privateStringmAdSpaceName=NATIVE_ADSPACE_NAME

publicvoidonCreate(Bundlebundle){
super.onCreate(bundle)
setContentView(R.layout.example)
mFlurryAdNative=newFlurryAdNative(this,mAdSpaceName)
//allowustogetcallbacksforadevents
mFlurryAdNative.setListener(nativeAdListener)
}
publicvoidonStart(){
super.onStart()
FlurryAgent.onStartSession(this)

//fetchanadforthisadspace.wontrenderoneyet
mFlurryAdNative.fetchAd()
}
publicvoidonStop(){
super.onStop()
FlurryAgent.onEndSession(this)
}

publicvoiddestroy(){
//destroytheadobject
mFlurryAdNative.destroy()
}

FlurryAdNativeListenernativeAdListener=newFlurryAdNativeListener(){

@Override
publicvoidonFetched(FlurryAdNativeadNative){

//Fetchallnativeadassetsandcreateyournativeadview.
FlurryAdNativeAssetheadlineAsset=adNative.getAsset(headline)
FlurryAdNativeAssetsummaryAsset=adNative.getAsset(summary)
FlurryAdNativeAssetsourceAsset=adNative.getAsset(source)
FlurryAdNativeAssetsponsoredImageUrl=
adNative.getAsset(secHqBrandingLogo)
FlurryAdNativeAssetsecHqImageAsset=
adNative.getAsset(secHqImage)
FlurryAdNativeAssetsecImageAsset=adNative.getAsset(secImage)

//FetchthedownArrowImageandupArrowImageforexpandableads
FlurryAdNativeAssetdownArrow=adNative.getAsset(downArrowImage)
FlurryAdNativeAssetupArrow=adNative.getAsset(upArrowImage)

//Getthelayoutandaddtheassets
RelativeLayoutmainLayout=(RelativeLayout)
findViewById(R.id.nativeAdLayout)

//Createaviewandshowtheseassets
TextViewheadlineView=(TextView)findViewById(R.id.headline)
headlineView.setText(headlineAsset.getValue())

//Note:Itismandatorytoshowsponsoredtextandimageinthe
nativead.
TextViewsponsoredText=(TextView)findViewById(R.id.sponsored)
sponsoredText.setText(SPONSORED)

//getAssets()forsecHqBrandingLogo,secHqImageandsecImage
returnstheurltotheimage.IftheimageisdownloadedbytheSDK
(dependinguponyourprecachingsettings)thisurlwillbethefilepath
onthedeviceotherwiseanhttpurltotheimage.

//setthetrackingviewonceyourviewiscreated.Werecommend
settingtheentireadviewastrackingview.
//Ifyouplantoreusetheviewtoshowdifferentads,docall
//adNative.removeTrackingView()beforesettingthenewtracking
view.

adNative.setTrackingView(mainLayout)

@Override

publicvoidonError(FlurryAdNativeadNative,FlurryAdErrorType
adErrorType,interrorCode){

switch(adErrorType){

caseFETCH:{

if(maxFetchTries<3){//maxFetchTriesisthecounterto
//checkhowmanytimeswehavetriedfetchinganad.If
//fetchAdfailsfor3times,destroythenativeadobject.

adNative.fetchAd()

}else{

adNative.destroy()

break

caseRENDER:{

adNative.destroy()

break

caseCLICK:{

adNative.destroy()

break

default:{

fAdStateText="unknownError"

break

@Override

publicvoidonShowFullscreen(FlurryAdNativeadNative){}

@Override

publicvoidonCloseFullscreen(FlurryAdNativeadNative){}

@Override

publicvoidonClicked(FlurryAdNativeadNative){}

@Override

publicvoidonImpressionLogged(FlurryAdNativeadNative){}

@Override
publicvoidonExpanded(FlurryAdNativeadNative){}
@Override
publicvoidonCollapsed(FlurryAdNativeadNative){}
@Override
publicvoidonAppExit(FlurryAdNativeadNative){}
}

Note:
YoucancreateNativeAdslayoutaccordingtotheapplicationslayout.Ifyouwanttosetalayout
whichhastwostateslikeacollapsedstate(withlessinformationaboutthead)andanexpandedstate(which
hasmoreinformationabouttheadyouareshowing),youcancreatedifferentlayoutforbothstates.Inorder
tosupporttwolayoutsimplementthetwo
onExpanded
and
onCollapsed
callbackmethodsin
FlurryAdNativeListener
andsetstheappropriate
setCollapsableTrackingView()
and
setExpandableTrackingView()
.

Samplecodebelow:
FlurryAdNativeListenernativeAdListener=newFlurryAdNativeListener(){

@Override

publicvoidonFetched(FlurryAdNativeadNative){

//Fetchallnativeadassetsandcreateyournativeadview.

//setthetrackingviewonceyourviewiscreated.
if(startsWithCollapsed){
onCollapsed(adNative)
}else{
onExpanded(adNative)
}

@Override

publicvoidonExpanded(FlurryAdNativeadNative){

//Enablethevisibilityofyourexpandedview.

expandablePanel.setVisibility(View.VISIBLE)

//GettheupArrowDrawableimageusingtheupArrowImageasset.

expandButton.setBackgroundDrawable(upArrowDrawable)

//Setthenewcollapseviewusingthismethod.Thismethodtakes
//twoparameters.Firstparameteristhetrackingviewusedfor
//impressionandclicktracking(sameassetTrackingViewmethod).

//Secondparameteristheviewwhichwhenclickedwillcollapse
//thisadviewfromexpandedtocollapsedstate.

adNative.setCollapsableTrackingView(mainLayout,collapseView)
}
@Override
publicvoidonCollapsed(FlurryAdNativeadNative){
//Disablethevisibilityofyourexpandedview.

expandablePanel.setVisibility(View.GONE)

//GetthedownArrowDrawableimageusingthedownArrowImageasset.

expandButton.setBackgroundDrawable(downArrowDrawable)

//Setthenewexpandtrackingviewusingthismethod.Thismethod
//takestwoparameters.Firstparameter(mainLayout)isthe
//trackingviewusedforimpressionandclicktracking(sameas
//setTrackingViewmethod).Secondparameter(moreButton)isthe
//viewwhichwhenclickedwilltaketheusertothelandingpageof
//thisad.Clickingonthisviewgivesanoptiontotheuserto
//directlylaunchorinstalltheadwithoutgoingtoanexpanded
//state.

adNative.setExpandableTrackingView(mainLayout,moreButton)
}

3.3.2NativeVideoAd
Startingfromversion5.6.0wehaveintroducedNativeVideoAd

publicclassExampleextendsActivity{
privateFlurryAdNativemFlurryAdNative=null
privateStringmAdSpaceName=NATIVE_ADSPACE_NAME

publicvoidonCreate(Bundlebundle){
super.onCreate(bundle)
setContentView(R.layout.example)

//YoucancreatenativeAdusingActivity/Applicationcontext
mFlurryAdNative=newFlurryAdNative(this,mAdSpaceName)

//Orpassapplicationcontextoncreationofactivityrecord
//if(savedInstanceState==null)
//{

//mFlurryAdNative=newFlurryAdNative(getApplicationContext(),
//
mAdSpaceName)

//}

//allowustogetcallbacksforadevents
mFlurryAdNative.setListener(nativeAdListener)
}
publicvoidonStart(){
super.onStart()
FlurryAgent.onStartSession(this)

//fetchandprepareadforthisadspace.wontrenderoneyet
mFlurryAdNative.fetchAd()
}
publicvoidonStop(){
super.onStop()
FlurryAgent.onEndSession(this)
}

//Destroy&refreshAdsherebasedonwhatcontextyouareusing
1. ApplicationcontextandOrientation
publicvoiddestroy(){
//ifusingapplicationcontext,dontdestroyadsonorientation
//change
//checkiftheActivityisactuallyfinishingcompletelyby
//belowflagthenonlydestroyadobjectsothatitsretained
//acrossorientationchanges
if(isFinishing()){
//DestroyAdobjectshere
mFlurryAdNative.destroy()
}

2. ActivitycontextandOrientation
//HeretheAdobjectscantpersistacrossorientationchangeas
//theactivitydestroyswewouldlosetheassociatedcontext.
//Tosupportvideoresume/pausefunctionalityonorientationchange
//useApplicationcontext.
publicvoiddestroy(){

//VideoAdswithActivitycontextwouldrequirerefetching
//theAdobject

@Override

publicvoidonFetched(FlurryAdNativeadNative){

//Fetchallnativeadassetsandcreateyournativeadview.
FlurryAdNativeAssetheadlineAsset=adNative.getAsset(headline)
FlurryAdNativeAssetsummaryAsset=adNative.getAsset(summary)
FlurryAdNativeAssetsourceAsset=adNative.getAsset(source)
FlurryAdNativeAssetsponsoredImageUrl=
adNative.getAsset(secHqBrandingLogo)

//GetthelayoutandaddtheassetsintheMainAdlayout
RelativeLayoutmainLayout=(RelativeLayout)
findViewById(R.id.nativeAdLayout)

//Getthechildlayout(childofmainLayout)whichcanholdthe
videoasset
RelativeLayoutvideoAdLayout=(RelativeLayout)
findViewById(R.id.videoAdLayout)

//Createaviewandshowtheseassets
TextViewheadlineView=(TextView)findViewById(R.id.headline)
headlineView.setText(headlineAsset.getValue())

//Note:Itismandatorytoshowsponsoredtextandimage/videoin
thenativead.
TextViewsponsoredText=(TextView)findViewById(R.id.sponsored)
sponsoredText.setText(SPONSORED)

//isVideoAd()wouldverifyifyoureceivedvideoAdornot
//
isexpectedtobeaViewGroupelement.
if(adNative.isVideoAd()){
loadAssetInView(adNative,"videoUrl",videoAdLayout)

//WerecommendcallingrequestLayout()onvideoAdLayout/mainLayout
//whenyouarereadytoshowthead

videoAdLayout.requestLayout()
}
//optionallyyoucouldhaveelsesectionwhereyoucanshowimageAd
ifyouhaverequestedbothImageandvideoadsbasedisVideoAd()return
value
else{
FlurryAdNativeAssetsecHqImageAsset=
adNative.getAsset(secHqImage)
}

//setthetrackingviewonceyourviewiscreated.Werecommend
settingtheentireadviewastrackingview.
//Ifyouplantoreusetheviewtoshowdifferentads,docall

//adNative.removeTrackingView()beforesettingthenewtracking
view.
//Evenforvideoweneedtheparentlayoutwhichwouldholdthe
completeAdfortrackingview.
adNative.setTrackingView(mainLayout)
}

NOTE:
1.
2.

3.

NativeVideoAddoesnotprovideimageassets.
Werecommendusingapplicationcontextwhenfetchingnativevideoadstosupportresumefeature
onorientationchange.Besuretodestroytheadswhentheactivityfinishes,andtorefetchadsfor
eachnewactivityrecord.Pleaseseesamplecodeabove.
Ifitispreferredtouseactivitycontext,besuretodestroyandrefetchadsuponactivity
destroyal/creation(whichincludesorientationchange).Notethatvideoswillnothaveresume
capability,andwillrestartfromthebeginning.

ImplementingFlurryAdNativeListenerforImageandVideoNativeAd
TobenotifiedofcertaineventsduringthefulllifecycleoftheAd,youshallimplementthe
FlurryAdNativeListener
interfaceandthencallthesetListenermethodtoattachyourimplementationof
FlurryAdNativeListener
totheFlurrySDK.Youwillneedtoimplementthefollowingcallbackmethods:

onClicked(FlurryAdNativeadNative)
Thismethodwillbecalledwhentheuserhasclickedonthead.
onImpressionLogged(FlurryAdNativeadNative)
Thismethodwillbecalledwhentheuserviewsthead.
onCloseFullscreen(FlurryAdNativeadNative)
ThismethodwillbecalledwhentheuserdismissesthecurrentAdfortheprovidedAdSpace
name.
onShowFullscreen(FlurryAdNativeadNative)
Thismethodwillbecalledwhentheuserhasopenedthead.
onAppExit(FlurryAdNativeadNative)
Thismethodwillbecalledwhentheuserisleavingtheapplicationafterfollowingevents
associatedwiththecurrentAdintheprovidedAdSpacename.
onRendered(FlurryAdNativeadNative)
Thismethodwillbecalledwhenadissuccessfullyrendered.
onError(FlurryAdNativeadNative,FlurryAdErrorTypeadErrorType,int
errorCode)
Thismethodwillbecalledwhenthereisfailurewithfetch,renderorclick.Therecanbe
manyreasonsforthefailure.Developermaywanttohandleeacherrordifferentlyand
provideaninputtouserforsomecases.
onFetched(FlurryAdNativeadNative)
Thismethodwillbecalledwhentheadhasbeenreceivedfromtheserver
onExpanded(FlurryAdNativeadNative)
Thismethodwillbecalledwhenthetheexpandablepanelisexpanded.
onColapsed(FlurryAdNativeadNative)
Thismethodwillbecalledwhenthetheexpandablepaneliscollapsed.


Note:pleasesee
AnalyticsREADME
fordetailson
FlurryAgent.onStartSession()

Herearethedetailsontheparameterstoadapis:
Contextcontext
WeadviseusingthecurrentActivity.
StringadSpace

Uniquenameofyouradplacement,maydefinedontheFlurrywebsite,but
doesnothavetobe
FlurryAdErrorType
adErrorType
Aderrortypes.

NativeAdTracking
Toenableimpressionandclicktracking,callsetTrackingView()onthemainadcontainerlayout.
adNative.setTrackingView(mainLayout)

Ifyouplantoreusetheviewtoshowdifferentads,docallremoveTrackingView()beforesetting
thenewadtrackingview.
adNative.removeTrackingView()

NativeAdExpiry
Afteranadisfetched,youcanexplicitlycheckiftheadisexpiredbyusingthe
adNative.isExpired()
api.
Iftheadisexpired,destroytheadobjectandfetchanotherad.

NativeAdsprecaching

Ifprecachingisenabledforagivenadspace,allprecacheableassetswillbecachedBEFOREtheadis
readyandwillavailableuntiltheadisdestroyed.Assetsareonlycachedondiskitisuptothedeveloperto
manageaninmemorycache.Noncachedassetswillbeloadeddirectlyfromthenetwork.

IfyouwishtoimplementamemorycacheitisrecommendedtoloadtheassetsdirectlyviaURLinsteadof
usingloadAssetIntoView/getAssetView.PleasenotethatprecachedasseturlsinFlurryAdNativeAssetwill
befile://andnonprecachedassetswillberegularhttps://urls.

3.Nativeadobjectlifecycle

FetchCycle

ClickCycle

4.AdditionalAdControls(Optional)

KeywordTargeting
Startingfromversion5.6.0wehavedeprecatedthisAPI.

VideoAds
Startingwithversion4.0.0,FlurryAndroidSDKsupportsprecachingofthevideoadsforenhanceduser
experienceandbettercompletionrate.PrecachingisdoneforvideoadsservedbyFlurrymarketplaceandby
FlurryFFA.

Sinceversion4.0.0,FlurrySDKsupportsdisplayingVASTLinear(includingVASTWrapper)adsfromFlurry
marketplace.

Thesefeaturesaresupportedautomaticallywithoutanyadditionalintegration.

5.EnablingAdNetworkMediation(Optional)

OnceyouhaveyourAdSpacessetup,youwillhavetheoptionofselecting3rdpartyadnetworkstoserve
adsintoyourAdSpacesusingtheFlurrywebsite(inadditiontoFFA,FFPandyourownads).Youcan
changewhichadnetworksserveadsatanytimeontheFlurrywebsite,butinordertoenablethemyouneed
toaddtheadnetworkSDKsintoyourapplicationandconfigurethem.ThelistofcurrentlysupportedAd
Networkscontains:

GoogleMobileAdsincludedautomaticallyinGooglePlayServicesSDK
MillennialSDKVersion5.3.0

InMobiSDKVersion4.5.3

ToimplementanAdNetworkyoumustperformthefollowingsteps:
1. IncludetheAdNetworkAndroidSDKwithyourappandaddittothebuildpath.Followthe
instructionsfromtheAdnetworkonhowtocompletethisstep.
2. CreatetheproperactivityandmetadatatagsinAndroidManifest.xml
a. thefirstmetadatataginstructstheSDKabouthowtofindtheAPI_KEY
b. thesecondmetadatataginstructstheSDKwhethertorequesttestads
3. AddyourAPI_KEYinstrings.xml

HereistheexampleofimplementingtheGoogleMobileAdsSDK:

AndroidManifest.xml
<activityandroid:name="com.google.android.gms.ads.AdActivity"

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|ui
Mode|screenSize|smallestScreenSize"/>

<metadataandroid:name="com.flurry.gms.ads.MY_AD_UNIT_ID"
android:value="@string/ffp_gms_apikey"/>

<metadataandroid:name="com.flurry.gms.ads.MYTEST_AD_DEVICE_ID"
android:value="@string/ffp_gms_testdevicekey"/>
<metadataandroid:name="com.flurry.gms.ads.test"
android:value="true"/>

strings.xml
<stringname="ffp_gms_apikey">YOUR_API_KEY</string>
<stringname="ffp_gms_testdevicekey">(adddeviceidthatshowsin
logcat</string>

Note:admob.testvalueneedstobesettotrueabove.Thiswillenableadmob
testadstoshowupintheemulatorandonadevice.

HereisanexampleofimplementingtheMillennialSDK:

AndroidManifest.xml

<activityandroid:name="com.millennialmedia.android.MMActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|ui
Mode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>

<metadata
android:name="com.flurry.millennial.MYAPID"
android:value="@string/ffp_millennial_apikey"/>
<metadata
android:name="com.flurry.millennial.MYAPIDINTERSTITIAL"
android:value="@string/ffp_millennial_apikey_interstitial"/>
<metadata
android:name="com.flurry.millennial.MYAPIDRECTANGLE"
android:value="@string/ffp_millennial_apikey_rectangle"/>
strings.xml
<stringname="ffp_millennial_apikey">YOUR_MILLENNIAL_API_KEY</string>
<string
name="ffp_millennial_apikey_interstitial">YOUR_MILLENNIAL_INTERSTITIAL_API_KEY</
string>
<string
name="ffp_millennial_apikey_rectangle">YOUR_MILLENNIAL_INTERSTITIAL_API_RECTANGL
E</string>

HereisanexampleofimplementingtheInmobiSDK:

AndroidManifest.xml
<activityandroid:name="com.inmobi.androidsdk.IMBrowserActivity
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|ui
Mode|screenSize|smallestScreenSize"
android:hardwareAccelerated="true"/>

<metadataandroid:name="com.flurry.imobi.APP_ID"
android:value="@string/ffp_inmobi_apikey"/>

strings.xml
<stringname="ffp_inmobi_apikey">YOUR_INMOBI_API_KEY</string>

6.AdTargetingOptions(Optional)

Startingfromversion5.6.0wehavedeprecatedsomeAdTargetingAPI.TosetAge(),setGender()and
setLocation()pleaseuseFlurryAnalyticsSDKAPI(FlurryAgentclassspecifically),wewillnotsupportthese
APIsinFlurryAdTargetingclass.

Option1.SetLocation

Startingfromversion5.6.0wehavedeprecatedlocationAPIinAdtargeting.
Deprecated
setLocation(floatlatitude,floatlongitude)

Deprecated
clearLocation()

Callthismethodtosetthecurrentlocation(usedwithgeographicaltargeting)usingAnalyticsAPI
FlurryAgent.setLocation(floatlatitude,floatlongitude)

Option2.UserCookies
Addacalltoidentifyanyuserspecificinformationyouwantassociatedwiththeadrequest:
setUserCookies(Map<String,String>cookies)

Toremoveanyusercookiescall:
clearUserCookies()

Option3.SetKeywords
Startingfromversion5.6.0wehavedeprecatedkeywordsAPIinAdtargeting.
Deprecated
setKeywords(Map<String,String>targetingKeywords)

Deprecated
clearKeywords()

Option4.SetAge
Startingfromversion5.6.0wehavedeprecatedageAPIinAdtargeting.
Deprecated
setAge(intage)

Deprecated
clearAge()

Tosettheageoftheuser,useAPIfromFlurryAnalyticsSDKtopassageinfo.
FlurryAgent.setAge()

Option5.SetGender
Startingfromversion5.6.0wehavedeprecatedgenderAPIinAdtargeting.
Deprecated
setGender(FlurryGendergender)

Deprecated
clearGender()

Tosetthegenderoftheuser,useAPIfromFlurryAnalyticsSDKtopassgenderinfo

FlurryAgent.setGender()

7.TumblrInAppSharing

FromFlurryAndroidAdsSDKrelease6.0.0onwards,youcanaddfewlinesofcodetoyour
applicationtoenableuserstosharecontenttoTumblr.Youwillbeabletotrackinteractionswith
thiscontentfromtheFlurrydevportal.

ToenableTumblrInAppSharingfollowthestepsbelow:

7.1LogintoFlurrydashboardandenablecontentsharing

Navigateto

YourApplication>Manage>AppInfo

andselectEnablecontent
sharing


7.2AddFlurryShareActivityinAndroidManifest.xml

PleaseincludetheFlurryShareActivityinyourAndroidManifest.xmlfile.Thisismandatoryto
showTumblrPost.AlsopleaseincludethethemementionedbelowtogetthedesiredUI
experience.

<activityandroid:name="com.flurry.android.FlurryShareActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|ui
Mode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>

7.3SettheConsumerApiKeyandsecret
Youcanusethebelowmentionedapitosettheconsumerapikeyandsecret:

importcom.flurry.android.tumblr.TumblrShare

StringapiKey=CONSUMER_API_KEY
Stringsecret=CONSUMER_API_SECRET
TumblrShare.
setOAuthConfig(apiKey,secret)

NOTE:YouwillneedtogenerateTumblroAuthkeysat
https://www.tumblr.com/oauth/apps
,and
then
email
bd@tumblr.com
torequestthatyourkeysarewhitelisted.

7.4ShowtheTumblrButton/ImageViewinyourfeed
IfyouwanttouseyourownTumblrbutton,pleasedosootherwiseusefollowingapitogetadefaultTumblr
buttonimage:

BitmaptumblrBtnBitmap=
TumblrShare
.getTumblrImage()

7.5Createandsendpost

7.5.1
CodesnippetforImagePost:

Note:westronglyrecommendthatyouincludedeeplinksforbothAndroidandiOSplatforms,as
wellasahighresolutionimageforyourpost.IfyourappdoesnotsupportiOS,youmay
passinawebURLpointingtoyourwebsiteinitsplace.

Stringurl="https://someexampleimage.com/123.jpg"
Stringcaption="Havinggreattime!"

ImagePostpost=newImagePost(url)
post.setCaption(caption)
post.setAndroidDeeplink("YourAppsAndroidDeepLinktocontent")//optional

post.setIOSDeepLink("YourAppsiOSDeepLinktoContent") //optional
post.setWebLink("YourAppsWebLink")
//optional
post.setPostListener(newPostListener(){

@Override

publicvoidonPostSuccess(StringpostId){
}

@Override

publicvoidonPostFailure(interrorCode,StringerrorMessage){

}
})
TumblrShare.post(context,post)

NOTE:

Urlfortheimagecannotbenull.

Urlcanonlybeavalidfileorhttp(s)url

Imageposturlismandatory.Pleasenotethatinordertoprovidegooduserexperience,itis
stronglyadvisedtoprovidedeeplinksandweblink.

IfyouarepostingavalidfiletoTumblrpleaseinclude
android.permission.READ_EXTERNAL_STORAGE
permissioninyourmanifestfile.

7.5.2
CodesnippetforTextPost:

Stringtitle="Posttitle"
//Posttitle
Stringbody="Postbody"
//Postbody

TextPostpost=newTextPost(body)
post.setTitle(title)
post.setAndroidDeeplink("YourAppsAndroidDeepLinktocontent")//optional
post.setIOSDeepLink("YourAppsiOSDeepLinktoContent") //optional
post.setWebLink("YourAppsWebLink")
//optional
post.setPostListener(newPostListener(){
@Override
publicvoidonPostSuccess(LongpostId){
}

@Override
publicvoidonPostFailure(StringerrorMessage){
}
})
TumblrShare.post(context,post)

NOTE:

Postbodycannotbenullorempty

Fortextpost,onlybodyismandatory.Allotherfieldsareoptional.Pleasenotethatinorderto
providegooduserexperience,itisstronglyadvisedtoprovidedeeplinksandweblink.


Listentothe
PostListener
eventstohandlethesuccessandfailurecasesappropriately.

7.6

Listenermethods

onPostSuccess
Firedwhenpostissuccessfullycreated.ItalsoreturnsthepostIdcreatedbyTumblr.
onPostFailure
Thislistenermethodisfiredwhenpostfailsduetoanyreason.Thislistenerisfiredwitha
userfriendlyerrorMessageexplainingthereasonforfailure.

8.UsingProGuard(Optional)
Ifyouplantorun

ProGuard
onyourAPKbeforereleasingyourapp,youwillneedtoaddthefollowingtoyour
proguard.cfgfile:

keepclasscom.flurry.**{*}
dontwarncom.flurry.**
keepattributes*Annotation*,EnclosingMethod
keepclasseswithmembersclass*{
public<init>(android.content.Context,android.util.AttributeSet,int)
}

#GooglePlayServiceslibrary
keepclass*extendsjava.util.ListResourceBundle{
protectedObject[][]getContents()
}

keeppublicclass
com.google.android.gms.common.internal.safeparcel.SafeParcelable{
publicstaticfinal***NULL
}

keepnames@com.google.android.gms.common.annotation.KeepNameclass*
keepclassmembernamesclass*{
@com.google.android.gms.common.annotation.KeepName*
}

keepnamesclass*implementsandroid.os.Parcelable{
publicstaticfinal**CREATOR
}

IfyouareusingtheGoogleMobileAdsSDK,addthefollowing:

#PreserveGMSadsclasses
keepclasscom.google.android.gms.ads.**{*}
dontwarncom.google.android.gms.ads.**

IfyouareusingtheGooglePlayServices,addthefollowing.

StartingAndroidMarshmallow,apachelibraryhasbeenremovedfromAndroid.GooglePlayServicesstill
needsapachelibrary.Pleaseaddtheproguardrulesmentionedbelowtoavoidcompilationissueswith
proguard.Seeissuehere:
https://code.google.com/p/androiddeveloperpreview/issues/detail?id=3001

#PreserveGMSclassestoenablefetchingtheAdvertisingID
keepclasscom.google.android.gms.**{*}
dontwarncom.google.android.gms.**

IfyouareusingtheInMobiSDK,addthefollowing:

#PreserveInMobiAdsclasses
keepclasscom.inmobi.**{*}
dontwarncom.inmobi.**

IfyouareusingtheMillennialMediaSDK,addthefollowing:

#PreserveMillennialAdsclasses
keepclassmembersclasscom.millennialmedia.android.*{
public*
}
keepclasscom.millennialmedia.android.*
dontwarncom.millennialmedia.**