[{"data":1,"prerenderedAt":231},["ShallowReactive",2],{"public-settings":3,"footer-custom-pages":18,"post-android-17-appfunctions-android-mcp-gemini":31,"article-code-1qlpenc":230},{"site_title":4,"tagline":5,"site_url":6,"footer_text":5,"social_twitter":7,"social_github":7,"social_youtube":7,"social_linkedin":7,"social_mastodon":7,"og_image":8,"comments_enabled":9,"ads_mode":10,"ads_publisher_id":11,"ads_adtest":12,"ads_in_article_enabled":9,"ads_in_article_slot":13,"ads_in_article_paragraph":14,"ads_end_of_post_enabled":9,"ads_end_of_post_slot":13,"ads_feed_enabled":9,"ads_feed_slot":13,"ads_feed_every":15,"ads_sidebar_enabled":9,"ads_sidebar_slot":13,"ads_consent_enabled":9,"clarity_enabled":12,"clarity_project_id":16,"seo_enabled":9,"llms_enabled":9,"verification_google":7,"verification_bing":7,"seo_home_title":7,"seo_description":7,"indexnow_key":7,"performance_lcp_preload":9,"pwa_enabled":9,"bookmarks_enabled":9,"comments_moderation":9,"home_carousel_featured":9,"home_carousel_latest":9,"home_carousel_latest_mode":17,"home_carousel_series":9,"home_carousel_topics":9},"Android Learner","Practical Android development, explained clearly.","https:\u002F\u002Fwww.androidlearner.com","","\u002Fmedia\u002Fseed\u002Fcover-llm.webp","1","live","ca-pub-3394535770235553","0","9901451769","2","3","jmrmm96ef6","latest",[19,26],{"id":20,"title":21,"slug":22,"show_in_footer":23,"sort_order":24,"updated_at":25},1,"Terms & Conditions","terms",true,10,"2026-11-28 13:13:48",{"id":27,"title":28,"slug":29,"show_in_footer":23,"sort_order":30,"updated_at":25},2,"Privacy Policy","privacy",20,{"post":32,"comments":229},{"id":33,"title":34,"slug":35,"path":36,"excerpt":37,"cover_image":38,"cover_media_id":39,"status":40,"publish_at":41,"reading_time":27,"seo_title":42,"seo_description":43,"og_image":38,"canonical_url":44,"noindex":45,"featured":45,"faq":46,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":54,"series":53,"tags":58,"author":76,"created_at":79,"updated_at":80,"body_md":81,"body_html":82,"related":83},23,"Android 17 AppFunctions & Android MCP: Exposing App Actions to Gemini","android-17-appfunctions-android-mcp-gemini","\u002Fposts\u002Fandroid-17-appfunctions-android-mcp-gemini","Android 17 expands AppFunctions so apps can expose structured actions to Gemini and Android MCP clients. Learn how to declare functions, validate inputs, and test locally.","\u002Fmedia\u002F2026\u002F11\u002F89e9aba2e88d1684.webp",65,"published","2026-11-28 15:45:00","Android 17 AppFunctions & Android MCP Guide","Learn how to expose structured in-app capabilities using Android 17 AppFunctions and Jetpack libraries for Gemini and Android MCP orchestration.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fandroid-17-appfunctions-android-mcp-gemini\u002F",false,[47,50],{"question":48,"answer":49},"Do AppFunctions replace deep links or App Actions?","No. Deep links still open specific screens from URLs or intents, while AppFunctions expose typed, callable capabilities that the system or an on-device assistant can invoke with structured parameters and receive a typed result.",{"question":51,"answer":52},"Can users or the OS restrict which AppFunctions run?","Yes. AppFunctions follow Android's permission and user-consent model, and sensitive actions should require explicit confirmation or foreground verification before mutating user data.",null,{"id":20,"name":55,"slug":56,"description":57},"On-device AI","on-device-ai","Running models on the phone, not the cloud.",[59,62,66,70,74],{"id":30,"name":60,"slug":61,"description":53},"AI Development","ai-development",{"id":63,"name":64,"slug":65,"description":53},28,"Android","android",{"id":67,"name":68,"slug":69,"description":53},35,"Android 17","android-17",{"id":71,"name":72,"slug":73,"description":53},3,"Gemini Nano","gemini-nano",{"id":75,"name":55,"slug":56,"description":53},51,{"id":20,"name":4,"username":77,"avatar":53,"profile_path":78},"superadmin","\u002Fu\u002Fsuperadmin","2026-11-28 10:11:52","2026-11-28 10:15:23","Android 17 shifts the platform from a traditional app launcher toward an **intelligence system** where users ask assistants like Gemini to complete tasks across apps. Instead of brittle UI scraping or one-off intent extras, **AppFunctions** and the **Android Model Context Protocol (MCP)** let your app publish typed, discoverable tools directly to the OS.\n\n## Why AppFunctions Matter in Android 17\n\nHistorically, letting an assistant act inside your app meant maintaining XML `shortcuts.xml` definitions or relying on custom voice intents. AppFunctions replace that glue with Kotlin-first annotations and generated schemas:\n\n- **Typed inputs and outputs**: Arguments and return values are serialized into structured schemas rather than untyped `Bundle` extras.\n- **On-device and MCP ready**: The same function contract can be surfaced to Gemini on-device or bridged through Android MCP tooling.\n- **Explicit capability boundaries**: You decide which domain actions are safe to expose (e.g., creating a note, toggling a timer, querying order status).\n\n## 1. Add the Jetpack AppFunctions Dependencies\n\nIn your app module's `build.gradle.kts`, add the AppFunctions runtime and KSP compiler so schemas are generated at build time:\n\n```kotlin\ndependencies {\n    implementation(\"androidx.appfunctions:appfunctions-runtime:1.0.0\")\n    ksp(\"androidx.appfunctions:appfunctions-compiler:1.0.0\")\n}\n```\n\n## 2. Declare an `@AppFunction` Service\n\nGroup related capabilities into a service class and annotate each exposed method with `@AppFunction`. Keep parameters flat, well-named, and documented—assistants rely on parameter names and KDoc descriptions to pick the right tool.\n\n```kotlin\nclass NotesAppFunctions(\n    private val notesRepository: NotesRepository\n) {\n    @AppFunction\n    suspend fun createQuickNote(\n        appFunctionContext: AppFunctionContext,\n        title: String,\n        body: String,\n        pinned: Boolean = false\n    ): CreatedNoteResult {\n        val note = notesRepository.insert(\n            title = title.trim(),\n            body = body.trim(),\n            pinned = pinned\n        )\n        return CreatedNoteResult(\n            noteId = note.id,\n            deepLink = \"myapp:\u002F\u002Fnotes\u002F${note.id}\"\n        )\n    }\n}\n```\n\n## 3. Return Actionable, Safe Results\n\nWhen an assistant invokes your function, return a concise result object containing an identifier and, if helpful, a deep link so the user can jump straight into the updated screen.\n\n```kotlin\n@AppFunctionSerializable\ndata class CreatedNoteResult(\n    val noteId: String,\n    val deepLink: String\n)\n```\n\n### Security & Validation Checklist\n\n1. **Validate every argument**: Treat assistant-supplied strings like untrusted network input—enforce length limits and sanitize paths.\n2. **Require confirmation for destructive actions**: Never delete records, send payments, or post publicly without an explicit user confirmation step.\n3. **Keep execution fast**: Offload heavy work to WorkManager and return a pending status if the operation takes more than a couple of seconds.\n\n## 4. Testing with Android MCP and Local Tooling\n\nDuring development, you can inspect your generated AppFunction schema in `build\u002Fgenerated\u002Fksp\u002F` and verify tool invocation using Android Studio's AppFunctions inspector or an MCP test harness before shipping to production.\n","\u003Cp>Android 17 shifts the platform from a traditional app launcher toward an \u003Cstrong>intelligence system\u003C\u002Fstrong> where users ask assistants like Gemini to complete tasks across apps. Instead of brittle UI scraping or one-off intent extras, \u003Cstrong>AppFunctions\u003C\u002Fstrong> and the \u003Cstrong>Android Model Context Protocol (MCP)\u003C\u002Fstrong> let your app publish typed, discoverable tools directly to the OS.\u003C\u002Fp>\n\u003Ch2 id=\"why-appfunctions-matter-in-android-17\">Why AppFunctions Matter in Android 17\u003C\u002Fh2>\n\u003Cp>Historically, letting an assistant act inside your app meant maintaining XML \u003Ccode>shortcuts.xml\u003C\u002Fcode> definitions or relying on custom voice intents. AppFunctions replace that glue with Kotlin-first annotations and generated schemas:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Typed inputs and outputs\u003C\u002Fstrong>: Arguments and return values are serialized into structured schemas rather than untyped \u003Ccode>Bundle\u003C\u002Fcode> extras.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>On-device and MCP ready\u003C\u002Fstrong>: The same function contract can be surfaced to Gemini on-device or bridged through Android MCP tooling.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Explicit capability boundaries\u003C\u002Fstrong>: You decide which domain actions are safe to expose (e.g., creating a note, toggling a timer, querying order status).\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"1-add-the-jetpack-appfunctions-dependencies\">1. Add the Jetpack AppFunctions Dependencies\u003C\u002Fh2>\n\u003Cp>In your app module's \u003Ccode>build.gradle.kts\u003C\u002Fcode>, add the AppFunctions runtime and KSP compiler so schemas are generated at build time:\u003C\u002Fp>\n\u003Cpre class=\"code-block\" data-lang=\"kotlin\">\u003Ccode class=\"language-kotlin\">dependencies {\n    implementation(&quot;androidx.appfunctions:appfunctions-runtime:1.0.0&quot;)\n    ksp(&quot;androidx.appfunctions:appfunctions-compiler:1.0.0&quot;)\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"2-declare-an-appfunction-service\">2. Declare an \u003Ccode>@AppFunction\u003C\u002Fcode> Service\u003C\u002Fh2>\n\u003Cp>Group related capabilities into a service class and annotate each exposed method with \u003Ccode>@AppFunction\u003C\u002Fcode>. Keep parameters flat, well-named, and documented—assistants rely on parameter names and KDoc descriptions to pick the right tool.\u003C\u002Fp>\n\u003Cpre class=\"code-block\" data-lang=\"kotlin\">\u003Ccode class=\"language-kotlin\">class NotesAppFunctions(\n    private val notesRepository: NotesRepository\n) {\n    @AppFunction\n    suspend fun createQuickNote(\n        appFunctionContext: AppFunctionContext,\n        title: String,\n        body: String,\n        pinned: Boolean = false\n    ): CreatedNoteResult {\n        val note = notesRepository.insert(\n            title = title.trim(),\n            body = body.trim(),\n            pinned = pinned\n        )\n        return CreatedNoteResult(\n            noteId = note.id,\n            deepLink = &quot;myapp:\u002F\u002Fnotes\u002F${note.id}&quot;\n        )\n    }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"3-return-actionable-safe-results\">3. Return Actionable, Safe Results\u003C\u002Fh2>\n\u003Cp>When an assistant invokes your function, return a concise result object containing an identifier and, if helpful, a deep link so the user can jump straight into the updated screen.\u003C\u002Fp>\n\u003Cpre class=\"code-block\" data-lang=\"kotlin\">\u003Ccode class=\"language-kotlin\">@AppFunctionSerializable\ndata class CreatedNoteResult(\n    val noteId: String,\n    val deepLink: String\n)\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3 id=\"security-validation-checklist\">Security &amp; Validation Checklist\u003C\u002Fh3>\n\u003Col>\n\u003Cli>\u003Cstrong>Validate every argument\u003C\u002Fstrong>: Treat assistant-supplied strings like untrusted network input—enforce length limits and sanitize paths.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Require confirmation for destructive actions\u003C\u002Fstrong>: Never delete records, send payments, or post publicly without an explicit user confirmation step.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Keep execution fast\u003C\u002Fstrong>: Offload heavy work to WorkManager and return a pending status if the operation takes more than a couple of seconds.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Ch2 id=\"4-testing-with-android-mcp-and-local-tooling\">4. Testing with Android MCP and Local Tooling\u003C\u002Fh2>\n\u003Cp>During development, you can inspect your generated AppFunction schema in \u003Ccode>build\u002Fgenerated\u002Fksp\u002F\u003C\u002Fcode> and verify tool invocation using Android Studio's AppFunctions inspector or an MCP test harness before shipping to production.\u003C\u002Fp>\n",[84,127,158,190],{"id":85,"title":86,"slug":87,"path":88,"excerpt":89,"cover_image":90,"cover_media_id":91,"status":40,"publish_at":92,"reading_time":27,"seo_title":93,"seo_description":94,"og_image":90,"canonical_url":95,"noindex":45,"featured":45,"faq":96,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":103,"series":53,"tags":108,"author":124,"created_at":125,"updated_at":126},27,"Jetpack AppState & Snapshot State Architecture: Beyond UI State","jetpack-appstate-snapshot-state-architecture","\u002Fposts\u002Fjetpack-appstate-snapshot-state-architecture","Compose's snapshot state system isn't just for UI. Learn how Jetpack AppState and snapshot-backed stores synchronize reactive state across screens, services, and widgets.","\u002Fmedia\u002F2026\u002F11\u002F3a2381e9f25fce93.webp",69,"2026-11-28 15:43:00","Jetpack AppState & Snapshot State Architecture in Android","Use Compose's snapshot state system and Jetpack AppState patterns to manage reactive state cleanly across ViewModels, background workers, and widgets.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fjetpack-appstate-snapshot-state-architecture\u002F",[97,100],{"question":98,"answer":99},"How is snapshot state different from MutableStateFlow?","Snapshot state tracks fine-grained property reads automatically without explicit combine\u002Fmap operators, and supports atomic multi-property transactions via Snapshot.withMutableSnapshot.",{"question":101,"answer":102},"Can snapshot state be used outside @Composable functions?","Yes. Compose Runtime's snapshot system has no Android View or UI dependency and can run in ViewModels, repositories, or background workers using snapshotFlow.",{"id":104,"name":105,"slug":106,"description":107},4,"Architecture","architecture","App architecture and data layers.",[109,110,112,116,120],{"id":63,"name":64,"slug":65,"description":53},{"id":111,"name":105,"slug":106,"description":53},48,{"id":113,"name":114,"slug":115,"description":53},24,"Jetpack","jetpack",{"id":117,"name":118,"slug":119,"description":53},18,"Jetpack Compose","jetpack-compose",{"id":121,"name":122,"slug":123,"description":53},5,"State hoisting","state-hoisting",{"id":20,"name":4,"username":77,"avatar":53,"profile_path":78},"2026-11-28 10:11:54","2026-11-28 10:14:38",{"id":128,"title":129,"slug":130,"path":131,"excerpt":132,"cover_image":133,"cover_media_id":134,"status":40,"publish_at":135,"reading_time":27,"seo_title":136,"seo_description":137,"og_image":133,"canonical_url":138,"noindex":45,"featured":45,"faq":139,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":146,"series":53,"tags":147,"author":156,"created_at":157,"updated_at":135},25,"Android 17's Mandatory Adaptive-First & Large-Screen Resizability Rules","android-17-adaptive-first-large-screen-resizability","\u002Fposts\u002Fandroid-17-adaptive-first-large-screen-resizability","Android 17 enforces adaptive-first layouts and large-screen resizability. Here is how to audit orientation locks, adopt WindowSizeClass, and ship ListDetailPaneScaffold.","\u002Fmedia\u002F2026\u002F11\u002F2df599bf25a8e4e3.webp",67,"2026-11-28 10:15:06","Android 17 Adaptive-First & Resizability Requirements","Prepare your Android app for Android 17's mandatory large-screen resizability and adaptive-first layout rules using WindowSizeClass and Material 3 adaptive scaffolds.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fandroid-17-adaptive-first-large-screen-resizability\u002F",[140,143],{"question":141,"answer":142},"Can I still lock screenOrientation=portrait on tablets and foldables in Android 17?","Android 17 removes legacy opt-outs for resizability on large screens (smallest width >= 600dp), meaning the system ignores fixed portrait\u002Flandscape locks and non-resizable flags.",{"question":144,"answer":145},"What is the fastest way to make an existing Compose screen adaptive?","Read currentWindowAdaptiveInfo() from Material 3 Adaptive, avoid hardcoded dp widths, and use ListDetailPaneScaffold or SupportingPaneScaffold for two-pane tablet and desktop layouts.",{"id":104,"name":105,"slug":106,"description":107},[148,149,150,151,152],{"id":63,"name":64,"slug":65,"description":53},{"id":67,"name":68,"slug":69,"description":53},{"id":111,"name":105,"slug":106,"description":53},{"id":117,"name":118,"slug":119,"description":53},{"id":153,"name":154,"slug":155,"description":53},46,"Material 3","material-3",{"id":20,"name":4,"username":77,"avatar":53,"profile_path":78},"2026-11-28 10:11:53",{"id":113,"title":159,"slug":160,"path":161,"excerpt":162,"cover_image":163,"cover_media_id":164,"status":40,"publish_at":165,"reading_time":27,"seo_title":166,"seo_description":167,"og_image":163,"canonical_url":168,"noindex":45,"featured":45,"faq":169,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":176,"series":53,"tags":178,"author":189,"created_at":157,"updated_at":165},"Google's \"Compose First\" Era: Migrating Legacy XML & RecyclerView Screens","compose-first-migrating-legacy-xml-recyclerview","\u002Fposts\u002Fcompose-first-migrating-legacy-xml-recyclerview","With android.widget Views, Fragments, and XML layout editors officially in maintenance mode, here is a practical, incremental playbook for migrating to Jetpack Compose.","\u002Fmedia\u002F2026\u002F11\u002F5f47e539df8d96b9.webp",66,"2026-11-28 10:14:54","Compose First Migration Guide: XML & RecyclerView to Compose","Step-by-step guide to migrating legacy Android XML layouts, Fragments, and RecyclerView adapters to Jetpack Compose without rewriting your entire app at once.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fcompose-first-migrating-legacy-xml-recyclerview\u002F",[170,173],{"question":171,"answer":172},"Do I have to rewrite my entire app to adopt Compose First?","No. You can embed Compose inside existing XML layouts with ComposeView, replace RecyclerView item types incrementally, and migrate Fragment navigation screen by screen.",{"question":174,"answer":175},"Are XML Views being removed from Android?","No, existing View APIs remain in the Android SDK for compatibility, but they are in maintenance mode—meaning critical bug fixes only, while all new UI capabilities ship in Jetpack Compose.",{"id":27,"name":118,"slug":119,"description":177},"Modern Android UI.",[179,180,181,184,185],{"id":63,"name":64,"slug":65,"description":53},{"id":111,"name":105,"slug":106,"description":53},{"id":104,"name":182,"slug":183,"description":53},"Compose","compose",{"id":117,"name":118,"slug":119,"description":53},{"id":186,"name":187,"slug":188,"description":53},31,"Recycler View","recycler-view",{"id":20,"name":4,"username":77,"avatar":53,"profile_path":78},{"id":191,"title":192,"slug":193,"path":194,"excerpt":195,"cover_image":196,"cover_media_id":197,"status":40,"publish_at":198,"reading_time":199,"seo_title":200,"seo_description":201,"og_image":196,"canonical_url":202,"noindex":45,"featured":45,"faq":203,"howto":53,"review_note":53,"submitted_at":53,"reviewed_at":53,"category":210,"series":53,"tags":214,"author":226,"created_at":227,"updated_at":228},22,"Google Play's 16 KB Page Size Rule: What to Fix Before 1 February 2027","android-16kb-page-size-google-play-deadline","\u002Fposts\u002Fandroid-16kb-page-size-google-play-deadline","Apps that target API 35+ and ship native code must support 16 KB pages before 1 February 2027 or Play will block updates. Pure Kotlin and Java apps are already compatible.","\u002Fmedia\u002F2026\u002F11\u002F723c07ce07ee95c5.webp",62,"2026-11-25 02:00:00",8,"Android 16 KB page size: Play deadline 1 February 2027","If your app targets API 35+ and ships native code, Google Play will block updates after 1 February 2027 unless you support 16 KB pages. How to check, rebuild, and test.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fandroid-16kb-page-size-google-play-deadline\u002F",[204,207],{"question":205,"answer":206},"Does a pure Kotlin or Java app need a native rebuild?","No. Android Developers say that if the app and all of its libraries are written only in Java or Kotlin, it already supports 16 KB devices. They still recommend testing on a 16 KB emulator image.",{"question":208,"answer":209},"Will Google remove my app from Play on 1 February 2027 if I miss the deadline?","The official compatibility section says you will not be able to release updates that do not support 16 KB pages. It does not say existing listings are removed. Check Play Console for the wording on your own app, and re-read the page-sizes guide for the current date.",{"id":121,"name":211,"slug":212,"description":213},"Performance","performance","Startup, frames, and profiles.",[215,216,220,224],{"id":63,"name":64,"slug":65,"description":53},{"id":217,"name":218,"slug":219,"description":53},49,"Google Play","google-play",{"id":221,"name":222,"slug":223,"description":53},50,"NDK","ndk",{"id":225,"name":211,"slug":212,"description":53},12,{"id":20,"name":4,"username":77,"avatar":53,"profile_path":78},"2026-11-24 19:51:51","2026-11-24 19:53:15",[],"\u003Cp>Android 17 shifts the platform from a traditional app launcher toward an \u003Cstrong>intelligence system\u003C\u002Fstrong> where users ask assistants like Gemini to complete tasks across apps. Instead of brittle UI scraping or one-off intent extras, \u003Cstrong>AppFunctions\u003C\u002Fstrong> and the \u003Cstrong>Android Model Context Protocol (MCP)\u003C\u002Fstrong> let your app publish typed, discoverable tools directly to the OS.\u003C\u002Fp>\n\u003Ch2 id=\"why-appfunctions-matter-in-android-17\">Why AppFunctions Matter in Android 17\u003C\u002Fh2>\n\u003Cp>Historically, letting an assistant act inside your app meant maintaining XML \u003Ccode>shortcuts.xml\u003C\u002Fcode> definitions or relying on custom voice intents. AppFunctions replace that glue with Kotlin-first annotations and generated schemas:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Typed inputs and outputs\u003C\u002Fstrong>: Arguments and return values are serialized into structured schemas rather than untyped \u003Ccode>Bundle\u003C\u002Fcode> extras.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>On-device and MCP ready\u003C\u002Fstrong>: The same function contract can be surfaced to Gemini on-device or bridged through Android MCP tooling.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Explicit capability boundaries\u003C\u002Fstrong>: You decide which domain actions are safe to expose (e.g., creating a note, toggling a timer, querying order status).\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"1-add-the-jetpack-appfunctions-dependencies\">1. Add the Jetpack AppFunctions Dependencies\u003C\u002Fh2>\n\u003Cp>In your app module's \u003Ccode>build.gradle.kts\u003C\u002Fcode>, add the AppFunctions runtime and KSP compiler so schemas are generated at build time:\u003C\u002Fp>\n\u003Cdiv class=\"code-block\" data-lang=\"kotlin\">\u003Cdiv class=\"code-block__header\">\u003Cspan class=\"code-block__lang\">kotlin\u003C\u002Fspan>\u003Cbutton type=\"button\" class=\"code-block__copy\" aria-label=\"Copy code\">Copy\u003C\u002Fbutton>\u003C\u002Fdiv>\u003Cdiv class=\"code-block__body\">\u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">dependencies\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    implementation\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"androidx.appfunctions:appfunctions-runtime:1.0.0\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    ksp\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"androidx.appfunctions:appfunctions-compiler:1.0.0\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Ch2 id=\"2-declare-an-appfunction-service\">2. Declare an \u003Ccode>@AppFunction\u003C\u002Fcode> Service\u003C\u002Fh2>\n\u003Cp>Group related capabilities into a service class and annotate each exposed method with \u003Ccode>@AppFunction\u003C\u002Fcode>. Keep parameters flat, well-named, and documented—assistants rely on parameter names and KDoc descriptions to pick the right tool.\u003C\u002Fp>\n\u003Cdiv class=\"code-block\" data-lang=\"kotlin\">\u003Cdiv class=\"code-block__header\">\u003Cspan class=\"code-block__lang\">kotlin\u003C\u002Fspan>\u003Cbutton type=\"button\" class=\"code-block__copy\" aria-label=\"Copy code\">Copy\u003C\u002Fbutton>\u003C\u002Fdiv>\u003Cdiv class=\"code-block__body\">\u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> NotesAppFunctions\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    private\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> val\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> notesRepository: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">NotesRepository\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    @AppFunction\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    suspend\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> fun\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> createQuickNote\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        appFunctionContext: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">AppFunctionContext\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        title: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        body: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        pinned: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Boolean\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> false\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    ): \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">CreatedNoteResult\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        val\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> note \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> notesRepository.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">insert\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            title \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> title.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">trim\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(),\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            body \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> body.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">trim\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(),\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            pinned \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> pinned\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        )\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">        return\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> CreatedNoteResult\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            noteId \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> note.id,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            deepLink \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"myapp:\u002F\u002Fnotes\u002F${note.id}\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        )\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Ch2 id=\"3-return-actionable-safe-results\">3. Return Actionable, Safe Results\u003C\u002Fh2>\n\u003Cp>When an assistant invokes your function, return a concise result object containing an identifier and, if helpful, a deep link so the user can jump straight into the updated screen.\u003C\u002Fp>\n\u003Cdiv class=\"code-block\" data-lang=\"kotlin\">\u003Cdiv class=\"code-block__header\">\u003Cspan class=\"code-block__lang\">kotlin\u003C\u002Fspan>\u003Cbutton type=\"button\" class=\"code-block__copy\" aria-label=\"Copy code\">Copy\u003C\u002Fbutton>\u003C\u002Fdiv>\u003Cdiv class=\"code-block__body\">\u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">@AppFunctionSerializable\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">data\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> CreatedNoteResult\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    val\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> noteId: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">String\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    val\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> deepLink: \u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">String\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Ch3 id=\"security-validation-checklist\">Security &amp; Validation Checklist\u003C\u002Fh3>\n\u003Col>\n\u003Cli>\u003Cstrong>Validate every argument\u003C\u002Fstrong>: Treat assistant-supplied strings like untrusted network input—enforce length limits and sanitize paths.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Require confirmation for destructive actions\u003C\u002Fstrong>: Never delete records, send payments, or post publicly without an explicit user confirmation step.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Keep execution fast\u003C\u002Fstrong>: Offload heavy work to WorkManager and return a pending status if the operation takes more than a couple of seconds.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Ch2 id=\"4-testing-with-android-mcp-and-local-tooling\">4. Testing with Android MCP and Local Tooling\u003C\u002Fh2>\n\u003Cp>During development, you can inspect your generated AppFunction schema in \u003Ccode>build\u002Fgenerated\u002Fksp\u002F\u003C\u002Fcode> and verify tool invocation using Android Studio's AppFunctions inspector or an MCP test harness before shipping to production.\u003C\u002Fp>\n",1795877411955]