Beruflich Dokumente
Kultur Dokumente
AndroidSDKInstructions
SDKversion4.0.0
Updated:03/24/2014
WelcometoFlurryAnalytics!
Thisfilecontains:
1.Introduction
2.IntegrationInstructions
3.OptionalFeatures
4.FAQ
1.Introduction
TheFlurryAndroidAnalyticsAgentallowsyoutotracktheusageandbehaviorofyourAndroidapplication
onusers'phonesforviewingintheFlurryAnalyticssystem.Itisdesignedtobeaseasyaspossible
withabasicsetupcompleteinfewminutes.
FlurryAnalyticsusestheAndroidAdvertisingIDprovidedbyGooglePlayServicesandwillcheckforand
respecttheuser'sadtrackingpreference.Formoreinformation,pleasevisit
https://developer.android.com/google/playservices/id.html
2.Integration
FlurryAnalyticsrequiresminimumAndroidAPIlevel10.TointegrateFlurryAnalyticsintoyourAndroid
application:
Step1.AddtheFlurryAnalytics_4.0.0.jarfiletoyourclasspath.
UsingAndroidStudio:
1. AddFlurryAnalytics 4.0.0.jartoyourproject'slibsfolder.
2. NavigatetoFile>ProjectStructure>Module>Dependencies.Clickthe+buttoninthebottomof
theProjectStructurepopuptoadddependencies.SelectFiledependencyandadd
libs/FlurryAnalytics 4.0.0.jar.
3. AddGooglePlayServiceslibrary.Pleasefollowinstructionsat
http://developer.android.com/google/playservices/setup.html#Setup
4. Addv4supportlibrary(orgreater).Pleasefollowinstructionsat
http://developer.android.com/tools/supportlibrary/features.html#v4
UsingEclipse:
1. AddFlurryAnalytics 4.0.0.jartoyourprojectslibsfolder.RightclickoneachJARfileandselect
BuildPath>AddtoBuildPath.
2. AddGooglePlayServicelibrary.Pleasefollowinstructionsat
http://developer.android.com/google/playservices/setup.html#Setup
3. Addv4/v7SupportLibrary.Pleasefollowinstructionsat
https://developer.android.com/tools/supportlibrary/setup.html#addlibrary.
Step2.ConfigureAndroidManifest.xml:
RequiredPermission:
android.permission.INTERNET
Requiredtosendanalyticsdatabacktotheflurryservers
OptionalPermission(HighlyRecommended):
android.permission.ACCESS_NETWORK_STATE
Ifyourapplicationhasnetworkstatepermissions,transmissionofanalyticsdatacanbeoptimized.
OptionalPermission:
android.permission.ACCESS_COARSE_LOCATIONor
android.permission.ACCESS_FINE_LOCATION
Ifyourapplicationhaslocationpermissions,analyticswilltrackwhereyourapplicationisbeing
used.Withoutthis,onlycountrylevellocationinformationwillbeavailable.Todisabledetailed
locationreportingevenwhenyourapphaspermission,call
FlurryAgent.setReportLocation(false)beforecalling
FlurryAgent.onStartSession()
SpecifyaversionNameattributeinthemanifesttohavedatareportedunderthatversionname.
Step3.AddcallstoonStartSessionandonEndSession
1. InsertacalltoFlurryAgent.onStartSession(Context,String),passingitareference
toaContextobject(suchasanActivityorService),andyourproject'sAPIkey.Werecommend
usingtheonStartmethodofeachActivityinyourapplication,andpassingtheActivity(orService)
itselfastheContextobjectpassingtheglobalApplicationcontextisnotrecommended.
2. InsertacalltoFlurryAgent.onEndSession(Context)whenasessioniscomplete.We
recommendusingtheonStopmethodofeachActivityinyourapplication.Makesuretomatchupa
calltoonEndSessionforeachcallofonStartSession,passinginthesameContextobjectthatwas
usedtocallonStartSession.
SolongasthereisanyContextthathascalledonStartSessionbutnotonEndSession,thesessionwillbe
continued.Also,ifanewContextcallsonStartSessionwithin10secondsofthelastContextcalling
onEndSession,thenthesessionwillberesumed,insteadofanewsessionbeingcreated.Sessionlength,
usagefrequency,eventsanderrorswillcontinuetobetrackedaspartofthesamesession.Thisensures
thatasausertransitionsfromoneActivitytoanotherinyourapplicationthattheywillnothaveaseparate
sessiontrackedforeachActivity,butwillhaveasinglesessionthatspansmanyactivities.Ifyouwantto
trackActivityusage,werecommendusinglogEvent,describedbelow.
Ifyouwishtochangethewindowduringwhichasessioncanberesumed,call
FlurryAgent.setContinueSessionMillis(longmilliseconds)beforethefirstcallto
FlurryAgent.onStartSession.
You'redone!That'sallyouneedtodotobeginreceivingbasicmetricdata.
3.OptionalFeatures
ReportAdditionalData
Youcanusethefollowingmethods(duringasessiononly)toreportadditionaldata:
FlurryAgent.logEvent(StringeventId)
FlurryAgent.logEvent(StringeventId,booleantimed)
FlurryAgent.logEvent(StringeventId,Map<String,String>parameters)
FlurryAgent.logEvent(StringeventId,Map<String,String>parameters,boolean
timed)
UseFlurryAgent.logEventtotrackusereventsthathappenduringasession.Youcantrackhowmany
timeseacheventoccurs,whatordereventshappenin,howlongeventsare,aswellaswhatthemost
commonparametersareforeachevent.Thiscanbeusefulformeasuringhowoftenuserstakevarious
actions,orwhatsequencesofactionstheyusuallyperform.Eachprojectsupportsamaximumof300event
names,andeacheventid,parameterkey,andparametervaluemustbenomorethan255charactersin
length.Eacheventcanhavenomorethan10parameters.Theparameterargumentisoptional,andmay
benull.Eachsessioncanlogupto200eventsandupto100uniqueeventnames.
FlurryAgent.endTimedEvent(StringeventId)
FlurryAgent.endTimedEvent(StringeventId,Map<String,String>parameters)
TimedeventcanbeloggedusingFlurryAgent.logEvent.UseendTimedEventtoendthetimedevent.
FlurryAgent.onError(StringerrorId,Stringmessage,Throwableexception)
UseonErrortoreporterrorsthatyourapplicationcatches.Flurrywillreportthefirst10errorstooccurin
eachsession.
FlurryAgent.setCaptureUncaughtExceptions(false)
Usedtoallow/disallowFlurrySDKtoreportuncaughtexceptions.Thefeatureisenabledbydefaultandif
youwouldliketodisablethisbehavior,thismustbecalledbeforecallingonStartSession.
FlurryAgent.onPageView()
UseonPageViewtoreportpageviewcount.Youshouldcallthismethodwheneveranewpageisshownto
theusertoincrementthetotalcount.Pageviewistrackedseparatelyfromevents.
FlurryAgent.setLogEvents(booleanlogEvents)
UsesetLogEventstoenable/disabletheeventlogging.
TrackingDemographics
FlurryAgent.setUserID(String)
Usethistologtheuser'sassignedIDorusernameinyoursystem.
FlurryAgent.setAge(int)
Usethistologtheuser'sage.Validinputsarebetween1and109.
FlurryAgent.setGender(byte)
Usethistologtheuser'sgender.ValidinputsareConstants.MALEorConstants.FEMALE.
FlurryAgent.setLocationCriteria(CriterialocationCriteria)
UsesetLocationCriteriatosettheandroid.location.Criteriaforlocationinformation.
AdditionalFeatures
FlurryAgent.setUseHttps(booleanuseHttps)
UsesetUseHttpstochangethesessionreportingrequesttouseHTTPorHTTPS.HTTPSisthedefault.
FlurryAgent.getReleaseVersion()
ReturnsastringcontainingcurrentFlurrySDKreleaseversion
FlurryAgent.setVersionName(StringversionName)
Setstheversionnameoftheapp.Thisnamewillappearinthehttp://dev.flurry.comasafilteringoptionby
version.
FlurryAgent.getAgentVersion()
GetstheversionoftheFlurrySDK.
FlurryAgent.setLocation(floatlatitude,floatlongitude)
Callthismethodtosetthecurrentlocation(usedwithgeographicaltargeting).
FlurryAgent.setLogLevel(intlogLevel)
SetsthelogleveloftheinternalFlurrySDKlogging.ValidinputsareLog.VERBOSE,Log.WARNetc.
DefaultloglevelisLog.WARN.
FlurryAgent.setLogEnabled(booleanisEnabled)
UsesetLogEnabledtoenable/disableinternalFlurrySDKlogging.
FlurryAgent.addOrigin(StringoriginName,StringoriginVersion)
FlurryAgent.addOrigin(StringoriginName,StringoriginVersion,Map<String,
String>originParameters)
UseaddOrigintoaddtheoriginattribution.TheeventisidentifiedbytheoriginName,originVersionand
originParameters.OriginParameterscanbepassedinasaMap<String,String>wherethekeyisthe
parametername,andthevalueisthevalue.
ProGuard
IfyouplantorunProGuardonyourAPKbeforereleasingyourapp,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
}
Pleaseletusknowifyouhaveanyquestions.Ifyouneedanyhelp,justemailandroidsupport@flurry.com!
Cheers,
TheFlurryTeam
http://www.flurry.com
androidsupport@flurry.com