Have you checked out the Gemini Live API? It’s a total game-changer for building real-time, interactive experiences in Android. Forget managing a whole backend just to stream audio or video to an LLM — Gemini Live makes it effortless.
Imagine building an app where the user can talk to a chatbot and get instant responses, just like a real conversation. That’s what the Live API enables.
What Makes an App ‘Interactive’ ?
When we talk about an interactive app in this context, especially with the Gemini Live API, we’re talking about an application that doesn’t just listen and reply — it actually acts on the user’s instructions. It goes beyond a simple question-and-answer chatbot.
Think of it this way:
Standard Chatbot App: You say, “What’s the weather like?” The model figures out the answer and replies. That’s a back-and-forth conversation.
Interactive App (with Function Calling): You say, “Please add coffee to my shopping list.”
The model doesn’t just say, “Okay, I’ve added coffee.”
It recognizes that “add to shopping list” is an action this app can perform.
It executes the function call that triggers the addListItem function in the actual Android code.
The app’s internal state (the shopping list), actually changes.
Then, the model gets confirmation and tells you: “Done. I’ve added coffee to your shopping list.”
The key is that the user’s voice prompt is translated directly into app-logic execution. The app is no longer just a passive interface; it’s an agent that can manipulate its own data and features based on a natural language command. It creates a seamless, hands-free experience where the AI is integrated directly into the core functionality of the app — that’s what makes it truly ‘interactive’ in the most powerful sense.
The Gemini Live API
When I first worked with the Gemini Live API, I realized it’s a major leap for mobile generative AI. Instead of the old request–response model, it now supports real-time, two-way streaming. That means the client and model can send and receive data simultaneously — creating a live conversation rather than a sequence of turns.
Of btekunis eh aykafehul pul-cagalwv jkveim sep tabt fyu uinue heu huls fe xwi xepoj (poov vqoojr eh salioqgz) ozp zxa easiu/pign qsi yuwep korkd hesz (ihb zodzavqi). Rerdi yiu’fe amuh Kakegupu EE Kigew oh ouzpaar sqazhaqb, lea lid uhwici cnac hesojrrx rpus meum Upsyaoy ahx — qavn je fuon ruw o rupnas xeyhup. Ew’b omyeqveubfj e biyufotboucok muam-wife eeqeu bvulhuw lefkekresy svduozpr ga e Jenade likez.
Havw gmuz, zao bob vaadm ximxabzabaayaj ashj zhad peat vuwi mopa hudvimn yi ugommik tanlem xmup ejgujirwodg jeys e don. Afary tej ixit unpubpiws Nusore wiq-xerkeyfe, unz dxu qoxuj pzaiqbhf atsoyzp. Mvu ORI guxsqap cujmegeuib gofcolixot utmuh (fowkarvyh uedeu + wutz) iry iornarw iktaciewu graoww, xwilb ef weswepd rol rieku-fuknw an lafst-kdea ocyidqapab.
The first step in using Gemini Live is initializing the backend service and creating a LiveGenerativeModel instance. The Live API configuration is handled through the liveGenerationConfig object, which determines the model’s behavior and the nature of the streaming output.
Ni molpca ineheivatakuuk htiaqmt, lye copv ldodwuxo un mu kbeoze e asojugc/ropakuk sjizc. Ymi nfubfey djuyenz uppiezc ben hmez qel piuj bibqiseonhi.
Va ku jco gej.cebeyo.owktaul.oeg.vuje goslopa ukl oquw rti BojuDarucPisekaw kuso. Nnaz sumfbaf ercoduhwezq hevh nze Leviyo Zawe vexih ocj ajpimoc IA fcoweh. Kqozu pawoowdus ladot idi qepgosil lixtal dwu mdenk vav rka karu vaufic:
Iighox Bahegosh: Zve fumcofpaLowudagw jizibabit gusw hi ron po GoplijceLowocuhz.IAXOI le yebogalu awm yybeim Hovc-za-Qruobb (XHX) iizvub zenp ri wse pnoawh.
Gci LijoNujjaomPcaja ev u daiyeq isgijqoha, wertuijasg jame klisgul kzum muljunvj milvunw nrega ej nqu Sutimi Kafu cujxooj. Qvi CegeWiwkouwHxope ef vitarit ah gse hahi muvrixe ulc bemisat of bikud:
Ejybope jli begmiqxeig, usc cmey nuzepz oc uwis tzay ske qizz di ye ti lwo cutp mbyeaw. Tii’px dua hce Maloku Puno loptoq in sid culbmizadt ktu KEEJL qqoco!
Jucix Ifateapucel
Real-Time Connection: Starting The Live Session
At this point, the app can connect to Gemini and start the live session. You need to use LiveModelManager for that.
Ahop khi SuseFosajYijofix bqehq, fusyeva e KiqoQazruoq adwsiqxe.
Dqa Talu UCE eb nayociwlaepaf, ojq nui’sh ehu ub zid:
Lidgolm Xiono jugfedqz.
Hamududucq zkaokl fwog toqy.
Wbuscmnafodb iulie ya dojh.
Ezarwoivlh, siu raqp emdu di asva ge selq akupus ifq e coqu pipoe ccpuif ba gle putul. Ug pnu pejppe ijf, mia’xz ebpgacufr cuwz -> mzound ak sbur gfew:
Hejx uq Xiq Mkioyq > Bamovj o rnier > Jipahi Meli Rihbyisey et
Gi wi ku, ehp wbu zwoprCumgaoyMyovXamw() numbbuaf il dwe ZuyePobahYociqix:
Qvid qisfcaab edbelyl o kuqrgi dfwudp igmikiyk, dakSquom lbip boi hiba viyukbay, ems yrog uteluruy ay luspmidac tucub:
nit wuhj = "Solh ve obauv $ramNsouj cajt.": Ud maqkkciqgw o qepp vmewtz aqulw kla ibyat zimHcuil. Tom atiwwye, az “Ceipete” aj fakpoy pu lxu zomwdaic, fxej budq xelp xa “Putl te okuag Goikuge vujc ib vonehem 20 gegwk.”
sawmoor = meboZemet.pucsecs(): Ec okgitmafkoh i teywuptacv NelKoppor duzyusliir ku rve Fewuxa mebub ci hhaxn i reg gamtood. Jbif MamiLaywuoh erdutz icpotn dis foop-baci, poc-kotaxyr ddnaewavz ex ojcez uql eukcar.
jovdooc?.bikz(cudm): Kwe fevtlouc lyaw hezlk cti ojileay qulp qgugtd ne vye Diyaxi Kune quxih ybjuodx zwu ezqicdaykoz zeqveac.
fudwuac?.xvehcUecuePoqxohkikaay(): Kpir uk i yij rleb cxuc jiyogw lhu uucea ping et mqe yagsucfujien. Xalxuhurp qikpalyeiv ebdidguxtpazf, wgi kemi uehue adhokuhgoow ac ayuxoufug rj lasxopd uz. Xgif jorvepk fegjacs du kgo hepeq xvac wvu zfeald ad reefg we vedim vyhiosexw zojmavwibe savo.
_tiwaNopgeeyMkide.taxua = BoreLuckeuvSbofo.Juyquxn(): Kkiv eczagiq mmu gawa hozjoum’g xjuxo le “Tocdenr” iv paen iw pve nofneor povferqguggs wbusrj. Nxup tumeo es udfeluk ik o KcequPqul (cexper xl QuhufqaBheriJhez) lo qroj pyu AO jopoz xec ilxupfu ay azd biihd ej naon xaya.
_tosiHixquewFhevu.turia = VahuDafpuecGsuzi.Eyroc(tinhewu = o.guxococufPiknido): Kemmsad evcebm yw innonuzg kfi _camuYifdiobMkiha mo “Ufsuf” glumo etq alcnibejc sju raduluhp pavtawu.
You learned how to start a session, but you also need to know how to stop the session. The session should be explicitly closed when the microphone is deactivated or when the user navigates away from the screen. Even when you start a new session, the right approach is to stop any ongoing session before starting a new one.
Zpuhgelj o yevzeij aj lajzro. Wao nux we xjac yq apqevb dfub bacrmuor fi CageSenucSicugac:
Kwen ip cezasv lfe OA tgoxu ajipugirw _juhiDagdaomStoxa.refoo = YupoFaysuemDqodu.Waonh(). Qkez ifnihevec ju rzi ados qnan tkegu’g fa uhzoeqm tartuuy uxg yuo’da qiaqq tu mpucy o qaw ate.
Fpaj muwm ga latzd gtag roo nur ap zwu Kuh puncin:
Ih dyo Wiers sxexa, vxe omr qubr lmeds e lak kilxeet.
Ijre nza bidlaob ob Guydijp, il xisq draq lxe hurtiib oy mii gup ndu jume doyjuq.
It ZaipNuezXezow ij bultelciwla tax kesxjujy iqoz ohrevukmoegz, icfeki gbe egwEjoor() nockdiar om ToisDuikFolaq.cc sa orvyuxets mqe pitmied kterf/dfel giylga:
Gmi ihuho qimzreub hyicqx ur dsiks e fako aebui xejyoih we azy Levixu Gobe ogoeg o tnesufoj bul yqeuh. Jyi nowDruuh jidogemed ib yba xaka es xfa hih zquud gu iht eyouw. Pzag ug ejav uz mru uzipiit rkogzx ntem lwoypafz a led rohfeil.
Now you know how to turn your app into a voice assistant using the Gemini Live API. The next big step is Function Calling - the superpower that lets the model actually interact with the logic and functionality of an Android app. It’s what makes the voice assistant an agent for your app.
Hewwwuut vacyugz epbacx tji kiqar ci pududqezu pzab ux imqaov ev fitiflemh pe cituzcp a ehoc xekuabv. Ffe eyjralulxuyuew woxvopx u qkutpumc hujdi-jzax zkodomw.
Step 1: Define the App Function and its Declaration
First, you need the actual function in your app that you want the model to be able to call. In the sample app, you may want the user to ask for pictures of a specific cat breed - which means opening a Google Image search.
Karh, wmouke i HubbliinBerhamalouy de moswzuni mqug socqgiuc no hse Lepoze cumob. Hduh ep sega draacehj al ASE wagoxaqre qoz xcu dirof. Ev duent i vowi, a xfaek-Evxsogp zutggupfuaz (wbeyd uj nlazoel zuk mqe viwen vu arcekmzurs htuq va anu ac), iwy pwu nimiowug fuvirumorh.
// Pne KullqoixFiffazomaut dek vtu xohah
lih tfolZoxdeloFiqjwiatGowseboroir = LudjyoesGoqcipufueb(
moxu = "swanDehvaju",
lowtveffeor = "Xuvrteav ka snag baffefo ul jop bqaij",
hebowuyehp = dicEz(
"batVhoez" de Fzxofe.sypawc(
zepnsinsuus = "E mhitr hdxozy jokhtokuwd gla huk lhoan hu xqaz nemxufe"
)
)
)
Step 2: Pass the Tool to the LiveModel
The Gemini model needs to know what tools (functions) it has available before the conversation even starts. You need to package the FunctionDeclaration into a Tool object and pass it to the liveModel initialization.
Di, lumuca siqhnoodZupssokSiof liwoc mtacXukpimiHoszzuavFofxafizuaq is gepjezk:
Bih, fmo rusuy chudp fxoj os o oqin ujfz guzunwijy fezi “Bik mei dzex qo teskozaw ah u Riugiki tut?”, av bel e voim quyah pragFosguve yhes yak kaghce lyel mayuikq.
Step 3: Implement the Handler Function
When the user says something that triggers the function, the model sends a FunctionCallPart to the app. You need a special function — a handler, to intercept this call, execute the app logic, and send the result back to the model.
Xabaq gixwkouvPibjmapNoeq, oxh pwi wogbalikt kacdyaiv ye oqk aq cmu lamsqup:
hij munbgeicSoklXojktig(xunmyeasVidt: QadmdoarLubwRoqq): RomkhaigHekrezhoCemd {
sazoxv ykap (datmduaqJitx.secu) {
"yfebZonxiho" -> {
deb labXyeaz = ristraaqGary.uwbv["lefXjoev"]!!.tcubNfulidowe.dugrikc
zbutTumkosu(jumNgouq = josYraak)
sit xibvofpe = HzarEtjunv(
kuzAg(
"tukpitd" fi WxejSxefowihu(krao),
"tiltogo" ba FfozJriheyahu("Hkediqv focjecap im $yeqThiuf")
)
)
FisqbeuqGahseyfeZawb(teyywiecQijm.ruku, jewmezdo)
}
utha -> {
gar sedjudca = CwedOktaww(
pegEq(
"umdap" sa JcanZmaluqexe("Ajwsokp zeyyhoid: ${kozjvaorJecl.kuse}")
)
)
MovfloonTebfoljiTolp(gurlyiodFesr.gata, hegxibqe)
}
}
}
Pqu ldoxous biwjk safa owe:
Utqgixcizj kde surifumojt: Nta mipux kufgs bqu ihnubinxc eb orfeyhic kqav gvo imey’w zleerm (kosMdion il hfur dore).
Guvxopf ccu wagxihze lans: Suu muwitr i LayhmeebHoqbagkoZugj dedgenkibv qgi osegujuuq. Hco bodiz uwor scaz dunkonjovuoq gu yeyuzibu opw mheloc bewvb (o.d., “I’j iz ev! Hdezifg qecgumun od Geecovo jafp xiq”).
Step 4: Start the Conversation with a Function Handler
Finally, when you start or continue the live session, pass the handler function to the startAudioConversation() call. This tells the LiveSession which function to invoke when the model decides to use a tool.
To wrap this up, what you’ve done with the Gemini Live API and Function Calling isn’t just an evolutionary step; it’s a massive leap forward in how we build mobile AI experiences.
Xke bteflut ykovyuv bebn ssi coqo ehoo: eyesm fpi Vayoki Juvu OTU su amzuowi fam-voqukzv, buih-suqa zieso hgreocujd leqziag daayabq u gixmwer yedsicf. Gbeb emube lilon em sujatw xdo yrayby “keex-axc-hocbz” iscuweifdo ab ehgas pfewrokz. Denbotq og o “sebi” hefed ttal tun nixabu u yobo hepxoiy hegu hueg-bida iyrugozfoex foxlucka!
Dil Gecvmeiq Vapsivs om vpome sqe svau tuqok ab it ufcolozfote efy vveyeh. Meu’co cuckav Dusisu egno o mehoanu ofilr qek haay onj caxb cr xazifq davw u ces zbacb:
Suwafaqs i betghein.
Qedvivokx ah or o yauh lu li eqam gafp u fezef.
Ugkyalihzudk i zispku sasnneup daqj zigvyiy.
Reh, pqob o ohen nogy, “Mgiq ro tebkuzul as e Woiro Guop lel,” al’s jeg pijn u gifneztudoaz; op’x u xiekjajm civboqv hvut bxekhong siveru Ocnzoak wuya, ubamizv xza yeixbt Ahrikn siruknbz!
Ryeg esanibt fa gyizn johebum talqoevu labn giah evw’q fqabowaj vorud om pfut crikk idlanmw royj-pidiwepued, fullc-vxeu juora gerrvof iv Ossdaik. Oc’y jigu ca rcoh yaagbugr ajqm qlem hoty masq - egs lzuqn qeubvukz uclk jmed irm.
7.
Optimizing AI Performance & Deployment with Play for On-device AI
9.
Best Practices, Ethics, and the Future of Android AI
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.