CINXE.COM
Services overview | Background work | Android Developers
<!doctype html> <html lang="en" dir="ltr"> <head> <base href="https://developer.android.com/develop/background-work/services"> <meta name="google-signin-client-id" content="721724668570-nbkv1cfusk7kk4eni4pjvepaus73b13t.apps.googleusercontent.com"> <meta name="google-signin-scope" content="profile email https://www.googleapis.com/auth/developerprofiles https://www.googleapis.com/auth/developerprofiles.award"> <meta property="og:site_name" content="Android Developers"> <meta property="og:type" content="website"> <meta name="theme-color" content="#34a853"> <meta charset="utf-8"> <meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="manifest" href="/_pwa/android/manifest.json" crossorigin="use-credentials"> <link rel="preconnect" href="//www.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.googleapis.com" crossorigin> <link rel="preconnect" href="//apis.google.com" crossorigin> <link rel="preconnect" href="//www.google-analytics.com" crossorigin> <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Google+Sans:400,500,600,700|Google+Sans+Text:400,400italic,500,500italic,600,600italic,700,700italic|Roboto+Mono:400,500,700&display=swap"> <link rel="stylesheet" href="//fonts.googleapis.com/css2?family=Material+Icons&family=Material+Symbols+Outlined&display=block"> <link rel="stylesheet" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/css/app.css"> <link rel="stylesheet" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/css/dark-theme.css" disabled> <link rel="shortcut icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/favicon.svg"> <link rel="apple-touch-icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/touchicon-180.png"> <link rel="canonical" href="https://developer.android.com/develop/background-work/services"> <link rel="search" type="application/opensearchdescription+xml" title="Android Developers" href="https://developer.android.com/s/opensearch.xml"> <link rel="alternate" hreflang="en" href="https://developer.android.com/develop/background-work/services"> <link rel="alternate" hreflang="x-default" href="https://developer.android.com/develop/background-work/services"> <link rel="alternate" hreflang="ar" href="https://developer.android.com/develop/background-work/services?hl=ar"> <link rel="alternate" hreflang="bn" href="https://developer.android.com/develop/background-work/services?hl=bn"> <link rel="alternate" hreflang="zh-Hans" href="https://developer.android.com/develop/background-work/services?hl=zh-cn"> <link rel="alternate" hreflang="zh-Hant" href="https://developer.android.com/develop/background-work/services?hl=zh-tw"> <link rel="alternate" hreflang="fa" href="https://developer.android.com/develop/background-work/services?hl=fa"> <link rel="alternate" hreflang="fr" href="https://developer.android.com/develop/background-work/services?hl=fr"> <link rel="alternate" hreflang="de" href="https://developer.android.com/develop/background-work/services?hl=de"> <link rel="alternate" hreflang="he" href="https://developer.android.com/develop/background-work/services?hl=he"> <link rel="alternate" hreflang="hi" href="https://developer.android.com/develop/background-work/services?hl=hi"> <link rel="alternate" hreflang="id" href="https://developer.android.com/develop/background-work/services?hl=id"> <link rel="alternate" hreflang="it" href="https://developer.android.com/develop/background-work/services?hl=it"> <link rel="alternate" hreflang="ja" href="https://developer.android.com/develop/background-work/services?hl=ja"> <link rel="alternate" hreflang="ko" href="https://developer.android.com/develop/background-work/services?hl=ko"> <link rel="alternate" hreflang="pl" href="https://developer.android.com/develop/background-work/services?hl=pl"> <link rel="alternate" hreflang="pt-BR" href="https://developer.android.com/develop/background-work/services?hl=pt-br"> <link rel="alternate" hreflang="ru" href="https://developer.android.com/develop/background-work/services?hl=ru"> <link rel="alternate" hreflang="es-419" href="https://developer.android.com/develop/background-work/services?hl=es-419"> <link rel="alternate" hreflang="th" href="https://developer.android.com/develop/background-work/services?hl=th"> <link rel="alternate" hreflang="tr" href="https://developer.android.com/develop/background-work/services?hl=tr"> <link rel="alternate" hreflang="vi" href="https://developer.android.com/develop/background-work/services?hl=vi"> <title>Services overview | Background work | Android Developers</title> <meta property="og:title" content="Services overview | Background work | Android Developers"> <meta property="og:url" content="https://developer.android.com/develop/background-work/services"> <meta property="og:image" content="https://developer.android.com/static/images/social/android-developers.png"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="675"> <meta property="og:locale" content="en"> <meta name="twitter:card" content="summary_large_image"> <script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Article", "headline": "Services overview" } </script> <script type="application/ld+json"> { "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "Develop", "item": "https://developer.android.com/develop" },{ "@type": "ListItem", "position": 2, "name": "Core areas", "item": "https://developer.android.com/develop/core-areas" },{ "@type": "ListItem", "position": 3, "name": "Background work", "item": "https://developer.android.com/develop/background-work" },{ "@type": "ListItem", "position": 4, "name": "Services overview", "item": "https://developer.android.com/develop/background-work/services" }] } </script> <link rel="stylesheet" href="/extras.css"> <meta http-equiv="X-Translated-By" content="Google"> <meta http-equiv="X-Translated-To" content="en"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.omlEigW4xY8.O/am=DgY/d=1/rs=AN8SPfpjsL9kUWY0h-sp7Ilu7hZWGwEmeg/m=corsproxy" data-sourceurl="https://developer.android.com/develop/background-work/services"></script> <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.omlEigW4xY8.O/am=DgY/d=1/exm=corsproxy/ed=1/rs=AN8SPfpjsL9kUWY0h-sp7Ilu7hZWGwEmeg/m=phishing_protection" data-phishing-protection-enabled="false" data-forms-warning-enabled="true" data-source-url="https://developer.android.com/develop/background-work/services"></script> <meta name="robots" content="none"> </head> <body class="" template="page" theme="android-theme" type="article" appearance layout="docs" display-toc pending> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.omlEigW4xY8.O/am=DgY/d=1/exm=corsproxy,phishing_protection/ed=1/rs=AN8SPfpjsL9kUWY0h-sp7Ilu7hZWGwEmeg/m=navigationui" data-environment="prod" data-proxy-url="https://developer-android-com.translate.goog" data-proxy-full-url="https://developer-android-com.translate.goog/develop/background-work/services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" data-source-url="https://developer.android.com/develop/background-work/services" data-source-language="auto" data-target-language="en" data-display-language="auto" data-detected-source-language="en" data-is-source-untranslated="false" data-source-untranslated-url="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://developer.android.com/develop/background-work/services&anno=2" data-client="tr"></script><devsite-progress type="indeterminate" id="app-progress"></devsite-progress> <section class="devsite-wrapper"><devsite-cookie-notification-bar></devsite-cookie-notification-bar><devsite-header role="banner"> <div class="devsite-header--inner nocontent"> <div class="devsite-top-logo-row-wrapper-wrapper"> <div class="devsite-top-logo-row-wrapper"> <div class="devsite-top-logo-row"><button type="button" id="devsite-hamburger-menu" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Navigation menu button" visually-hidden aria-label="Open menu"> </button> <div class="devsite-product-name-wrapper"><a href="https://developer-android-com.translate.goog/?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="androidDevelopers" track-metadata-position="nav" track-metadata-eventdetail="nav"> <picture> <source srcset="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup-dark-theme.svg" media="(prefers-color-scheme: dark)" class="devsite-dark-theme" alt="Android Developers"> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup.svg" class="devsite-site-logo" alt="Android Developers"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list"> <li class="devsite-breadcrumb-item "></li> </ul></span> </div> <div class="devsite-top-logo-row-middle"> <div class="devsite-header-upper-tabs"><devsite-tabs class="upper-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Upper tabs"><tab class="devsite-dropdown devsite-dropdown-full "> <a href="https://developer-android-com.translate.goog/get-started?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-metadata-eventdetail="https://developer.android.com/get-started" class="devsite-tabs-content gc-analytics-event android-dropdown-tab" track-type="nav" track-metadata-position="nav - essentials" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Essentials" track-name="essentials"> Essentials </a> <a href="https://developer-android-com.translate.goog/develop/background-work/services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Essentials" track-type="nav" track-metadata-eventdetail="https://developer.android.com/get-started" track-metadata-position="nav - essentials" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Essentials" track-name="essentials" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column android-dropdown android-dropdown-primary android-dropdown-studio"> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-title" role="heading" tooltip>Gemini in Android Studio</li> <li class="devsite-nav-description">Your AI development companion for Android development.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/gemini-in-android?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/gemini-in-android" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="gemini in android studio" tooltip class="button button-primary"> <div class="devsite-nav-item-title"> Learn more </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/studio?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/studio" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="gemini in android studio" tooltip class="button button-white"> <div class="devsite-nav-item-title"> Get Android Studio </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-launch"> <li class="devsite-nav-title" role="heading" tooltip>Get started</li> <li class="devsite-nav-description">Start by creating your first app. Go deeper with our training courses or explore app development on your own.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/get-started/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/get-started/overview" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip> <div class="devsite-nav-item-title"> Hello world </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/courses?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/courses" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip> <div class="devsite-nav-item-title"> Training courses </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/get-started/codelabs?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/get-started/codelabs" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip> <div class="devsite-nav-item-title"> Tutorials </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/kotlin?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/kotlin" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip> <div class="devsite-nav-item-title"> Kotlin for Android </div></a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://play.google.com/console/about/guides/monetize/" track-type="nav" track-metadata-eventdetail="https://play.google.com/console/about/guides/monetize/" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip> <div class="devsite-nav-item-title"> Monetization with Play ↗️ </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-multiple-screens"> <li class="devsite-nav-title" role="heading" tooltip>Extend by device</li> <li class="devsite-nav-description">Build apps that give your users seamless experiences from phones to tablets, watches, and more.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/adaptive-apps?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/adaptive-apps" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip> <div class="devsite-nav-item-title"> Adaptive apps </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/wear?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/wear" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip> <div class="devsite-nav-item-title"> Wear OS </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/cars?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/cars" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip> <div class="devsite-nav-item-title"> Android for Cars </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/tv?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/tv" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip> <div class="devsite-nav-item-title"> Android TV </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/chrome-os?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/chrome-os" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip> <div class="devsite-nav-item-title"> ChromeOS </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/multi-device-development?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/multi-device-development" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip> <div class="devsite-nav-item-title"> Cross-device SDK </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-platform"> <li class="devsite-nav-title" role="heading" tooltip>Build by category</li> <li class="devsite-nav-description">Learn to build for your use case by following Google's prescriptive and opinionated guidance.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/games?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/games" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip> <div class="devsite-nav-item-title"> Games </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/media?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/media" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip> <div class="devsite-nav-item-title"> Camera & Media </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/social-and-messaging?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/social-and-messaging" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip> <div class="devsite-nav-item-title"> Social & messaging </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/health-and-fitness?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/health-and-fitness" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip> <div class="devsite-nav-item-title"> Health & Fitness </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/productivity?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/productivity" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip> <div class="devsite-nav-item-title"> Productivity </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/work/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/work/overview" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip> <div class="devsite-nav-item-title"> Enterprise apps </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-stars"> <li class="devsite-nav-title" role="heading" tooltip>Get the latest</li> <li class="devsite-nav-description">Stay in touch with the latest releases throughout the year, join our preview programs, and give us your feedback.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/latest-updates?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/latest-updates" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip> <div class="devsite-nav-item-title"> Latest updates </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/latest-updates/experimental?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/latest-updates/experimental" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip> <div class="devsite-nav-item-title"> Experimental updates </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/studio/preview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/studio/preview" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip> <div class="devsite-nav-item-title"> Android Studio preview </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/jetpack/androidx/versions?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/jetpack/androidx/versions" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip> <div class="devsite-nav-item-title"> Jetpack & Compose libraries </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/wearables/versions/4?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/wearables/versions/4" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip> <div class="devsite-nav-item-title"> Wear OS preview </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design-for-safety/privacy-sandbox?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design-for-safety/privacy-sandbox" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip> <div class="devsite-nav-item-title"> Privacy Sandbox </div></a></li> </ul> </div> </div> </div> </tab> <tab class="devsite-dropdown devsite-dropdown-full "> <a href="https://developer-android-com.translate.goog/design?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-metadata-eventdetail="https://developer.android.com/design" class="devsite-tabs-content gc-analytics-event android-dropdown-tab" track-type="nav" track-metadata-position="nav - design & plan" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Design & Plan" track-name="design & plan"> Design & Plan </a> <a href="https://developer-android-com.translate.goog/develop/background-work/services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Design & Plan" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design" track-metadata-position="nav - design & plan" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Design & Plan" track-name="design & plan" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-layout"> <li class="devsite-nav-title" role="heading" tooltip>UI Design</li> <li class="devsite-nav-description">Design a beautiful user interface using Android best practices.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip> <div class="devsite-nav-item-title"> Design for Android </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/mobile?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/mobile" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip> <div class="devsite-nav-item-title"> Mobile </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/large-screens?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/large-screens" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip> <div class="devsite-nav-item-title"> Large screens (e.g., tablets) </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/widget?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/widget" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip> <div class="devsite-nav-item-title"> Widgets </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/wear?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/wear" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip> <div class="devsite-nav-item-title"> Wear OS </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/tv?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/tv" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip> <div class="devsite-nav-item-title"> Android TV </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-design"> <li class="devsite-nav-title" role="heading" tooltip>Architecture</li> <li class="devsite-nav-description">Design robust, testable, and maintainable app logic and services.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/topic/architecture/intro?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/topic/architecture/intro" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip> <div class="devsite-nav-item-title"> Introduction </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/topic/libraries/view-binding?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/topic/libraries/view-binding" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip> <div class="devsite-nav-item-title"> Libraries </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/navigation/navigation-principles?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/navigation/navigation-principles" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip> <div class="devsite-nav-item-title"> Navigation </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/topic/modularization?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/topic/modularization" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip> <div class="devsite-nav-item-title"> Modularization </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/testing/fundamentals?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/testing/fundamentals" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip> <div class="devsite-nav-item-title"> Testing </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-vitals"> <li class="devsite-nav-title" role="heading" tooltip>Quality</li> <li class="devsite-nav-description">Plan for app quality and align with Play store guidelines.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip> <div class="devsite-nav-item-title"> Overview </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality/core-value?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality/core-value" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip> <div class="devsite-nav-item-title"> Core value </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality/user-experience?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality/user-experience" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip> <div class="devsite-nav-item-title"> User experience </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality/technical?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality/technical" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip> <div class="devsite-nav-item-title"> Technical quality </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality/privacy-and-security?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality/privacy-and-security" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip> <div class="devsite-nav-item-title"> Security </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-security-2"> <li class="devsite-nav-title" role="heading" tooltip>Security</li> <li class="devsite-nav-description">Safeguard users against threats and ensure a secure Android experience.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/security?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/security" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="security" tooltip> <div class="devsite-nav-item-title"> Overview </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/privacy-and-security/about?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/privacy-and-security/about" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="security" tooltip> <div class="devsite-nav-item-title"> Privacy </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/identity?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/identity" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="security" tooltip> <div class="devsite-nav-item-title"> Identity </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/security/fraud-prevention?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/security/fraud-prevention" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="security" tooltip> <div class="devsite-nav-item-title"> Fraud prevention </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-earth"> <li class="devsite-nav-title" role="heading" tooltip>Build for Billions</li> <li class="devsite-nav-description">Create the best experience for entry-level devices</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/build-for-billions?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/build-for-billions" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="build for billions" tooltip> <div class="devsite-nav-item-title"> Overview </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/docs/quality-guidelines/build-for-billions?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/docs/quality-guidelines/build-for-billions" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="build for billions" tooltip> <div class="devsite-nav-item-title"> About new markets </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/androidgo?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/androidgo" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="build for billions" tooltip> <div class="devsite-nav-item-title"> Android (Go edition) </div></a></li> </ul> </div> </div> </div> </tab> <tab class="devsite-dropdown devsite-dropdown-full devsite-active "> <a href="https://developer-android-com.translate.goog/develop?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-metadata-eventdetail="https://developer.android.com/develop" class="devsite-tabs-content gc-analytics-event android-dropdown-tab" track-type="nav" track-metadata-position="nav - develop" track-metadata-module="primary nav" aria-label="Develop, selected" data-category="Site-Wide Custom Events" data-label="Tab: Develop" track-name="develop"> Develop </a> <a href="https://developer-android-com.translate.goog/develop/background-work/services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Develop" track-type="nav" track-metadata-eventdetail="https://developer.android.com/develop" track-metadata-position="nav - develop" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Develop" track-name="develop" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column android-dropdown android-dropdown-primary android-dropdown-ai"> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-title" role="heading" tooltip>Build AI experiences</li> <li class="devsite-nav-description">Build AI-powered Android apps with Gemini APIs and more.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/ai?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/ai" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="build ai experiences" tooltip class="button button-primary"> <div class="devsite-nav-item-title"> Get started </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-flag"> <li class="devsite-nav-title" role="heading" tooltip>Core areas</li> <li class="devsite-nav-description">Get the samples and docs for the features you need.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/samples?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/samples" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip> <div class="devsite-nav-item-title"> Samples </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quick-guides?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quick-guides" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip> <div class="devsite-nav-item-title"> Try Quick Guidesᵇᵉᵗᵃ </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/ui?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/develop/ui" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip> <div class="devsite-nav-item-title"> User interfaces </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/permissions/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/permissions/overview" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip> <div class="devsite-nav-item-title"> Permissions </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/develop/background-work" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip> <div class="devsite-nav-item-title"> Background work </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/data?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/data" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip> <div class="devsite-nav-item-title"> Data and files </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#core-areas" track-type="nav" track-metadata-eventdetail="https://developer.android.com/develop#core-areas" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip> <div class="devsite-nav-item-title"> All core areas ⤵️ </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-tools-2"> <li class="devsite-nav-title" role="heading" tooltip>Tools and workflow</li> <li class="devsite-nav-description">Use the IDE to write and build your app, or create your own pipeline.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/studio/write?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/studio/write" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip> <div class="devsite-nav-item-title"> Write and debug code </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/build/gradle-build-overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/build/gradle-build-overview" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip> <div class="devsite-nav-item-title"> Build projects </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/testing?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/testing" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip> <div class="devsite-nav-item-title"> Test your app </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/topic/performance/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/topic/performance/overview" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip> <div class="devsite-nav-item-title"> Performance </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/tools?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/tools" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip> <div class="devsite-nav-item-title"> Command-line tools </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/reference/tools/gradle-api?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/reference/tools/gradle-api" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip> <div class="devsite-nav-item-title"> Gradle plugin API </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-multiple-screens"> <li class="devsite-nav-title" role="heading" tooltip>Device tech</li> <li class="devsite-nav-description">Write code for form factors. Connect devices and share data.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/large-screens/get-started-with-large-screens?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/large-screens/get-started-with-large-screens" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip> <div class="devsite-nav-item-title"> Large screens (e.g., tablets) </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/wearables?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/wearables" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip> <div class="devsite-nav-item-title"> Wear OS </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/health-and-fitness/guides?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/health-and-fitness/guides" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip> <div class="devsite-nav-item-title"> Android Health </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/connectivity/cross-device-sdk/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/connectivity/cross-device-sdk/overview" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip> <div class="devsite-nav-item-title"> Cross-device SDK </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/cars?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/cars" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip> <div class="devsite-nav-item-title"> Android for Cars </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/tv?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/tv" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip> <div class="devsite-nav-item-title"> Android TV </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/chrome-os/intro?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/chrome-os/intro" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip> <div class="devsite-nav-item-title"> ChromeOS </div></a></li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-core-library"> <li class="devsite-nav-title" role="heading" tooltip>Libraries</li> <li class="devsite-nav-description">Browse API reference documentation with all the details.</li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/reference/packages?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/reference/packages" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip> <div class="devsite-nav-item-title"> Android platform </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/jetpack/androidx/explorer?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/jetpack/androidx/explorer" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip> <div class="devsite-nav-item-title"> Jetpack libraries </div></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/jetpack/androidx/releases/compose?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-type="nav" track-metadata-eventdetail="https://developer.android.com/jetpack/androidx/releases/compose" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip> <div class="devsite-nav-item-title"> Compose libraries </div></a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://developers.google.com/android/reference/packages" track-type="nav" track-metadata-eventdetail="https://developers.google.com/android/reference/packages" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip> <div class="devsite-nav-item-title"> Google Play services ↗️ </div></a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://play.google.com/sdks" track-type="nav" track-metadata-eventdetail="https://play.google.com/sdks" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip> <div class="devsite-nav-item-title"> Google Play SDK index ↗️ </div></a></li> </ul> </div> </div> </div> </tab> <tab> <a href="https://developer-android-com.translate.goog/distribute?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-metadata-eventdetail="https://developer.android.com/distribute" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - google play" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Google Play" track-name="google play"> Google Play </a> </tab> <tab> <a href="https://developer-android-com.translate.goog/community?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" track-metadata-eventdetail="https://developer.android.com/community" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - community" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community"> Community </a> </tab> </nav> </devsite-tabs> </div><devsite-search enable-signin enable-search enable-suggestions enable-query-completion project-name="Background work" tenant-name="Android Developers"> <form class="devsite-search-form" action="https://developer.android.com/s/results" method="GET"> <div class="devsite-search-container"><button type="button" search-open class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Open search"></button> <div class="devsite-searchbox"><input aria-activedescendant="" aria-autocomplete="list" aria-label="Search" aria-expanded="false" aria-haspopup="listbox" autocomplete="off" class="devsite-search-field devsite-search-query" name="q" placeholder="Search" role="combobox" type="text" value=""> <div class="devsite-search-image material-icons" aria-hidden="true"> </div> <div class="devsite-search-shortcut-icon-container" aria-hidden="true"><kbd class="devsite-search-shortcut-icon">/</kbd> </div> </div> </div> </form> <button type="button" search-close class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Close search"></button> </devsite-search> </div><devsite-appearance-selector></devsite-appearance-selector> <devsite-language-selector> <ul role="presentation"> <li role="presentation"><a role="menuitem" lang="en">English</a></li> <li role="presentation"><a role="menuitem" lang="de">Deutsch</a></li> <li role="presentation"><a role="menuitem" lang="es_419">Español – América Latina</a></li> <li role="presentation"><a role="menuitem" lang="fr">Français</a></li> <li role="presentation"><a role="menuitem" lang="id">Indonesia</a></li> <li role="presentation"><a role="menuitem" lang="it">Italiano</a></li> <li role="presentation"><a role="menuitem" lang="pl">Polski</a></li> <li role="presentation"><a role="menuitem" lang="pt_br">Português – Brasil</a></li> <li role="presentation"><a role="menuitem" lang="vi">Tiếng Việt</a></li> <li role="presentation"><a role="menuitem" lang="tr">Türkçe</a></li> <li role="presentation"><a role="menuitem" lang="ru">Русский</a></li> <li role="presentation"><a role="menuitem" lang="he">עברית</a></li> <li role="presentation"><a role="menuitem" lang="ar">العربيّة</a></li> <li role="presentation"><a role="menuitem" lang="fa">فارسی</a></li> <li role="presentation"><a role="menuitem" lang="hi">हिंदी</a></li> <li role="presentation"><a role="menuitem" lang="bn">বাংলা</a></li> <li role="presentation"><a role="menuitem" lang="th">ภาษาไทย</a></li> <li role="presentation"><a role="menuitem" lang="zh_cn">中文 – 简体</a></li> <li role="presentation"><a role="menuitem" lang="zh_tw">中文 – 繁體</a></li> <li role="presentation"><a role="menuitem" lang="ja">日本語</a></li> <li role="presentation"><a role="menuitem" lang="ko">한국어</a></li> </ul> </devsite-language-selector> <a class="devsite-header-link devsite-top-button button gc-analytics-event" href="https://developer-android-com.translate.goog/studio?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" data-category="Site-Wide Custom Events" data-label="Site header link"> Android Studio </a> <devsite-user enable-profiles id="devsite-user"> <span class="button devsite-top-button" aria-hidden="true" visually-hidden>Sign in</span> </devsite-user> </div> </div> </div> <div class="devsite-collapsible-section devsite-header-no-lower-tabs "> <div class="devsite-header-background"> <div class="devsite-product-id-row"> <div class="devsite-product-description-row"> <ul class="devsite-breadcrumb-list" aria-label="Lower header breadcrumb"> <li class="devsite-breadcrumb-item "><a href="https://developer-android-com.translate.goog/develop/core-areas?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Lower Header" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="Core areas"> Core areas </a></li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div><a href="https://developer-android-com.translate.goog/develop/background-work?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Lower Header" data-value="2" track-type="globalNav" track-name="breadcrumb" track-metadata-position="2" track-metadata-eventdetail="Background work"> Background work </a></li> </ul> </div> </div> </div> </div> </div> </devsite-header> <devsite-book-nav scrollbars> <div class="devsite-book-nav-filter"><span class="filter-list-icon material-icons" aria-hidden="true"></span> <input type="text" placeholder="Filter" aria-label="Type to filter" role="searchbox"> <span class="filter-clear-button hidden" data-title="Clear filter" aria-label="Clear filter" role="button" tabindex="0"></span> </div> <nav class="devsite-book-nav devsite-nav nocontent" aria-label="Side menu"> <div class="devsite-mobile-header"><button type="button" id="devsite-close-nav" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Close navigation" aria-label="Close navigation"> </button> <div class="devsite-product-name-wrapper"><a href="https://developer-android-com.translate.goog/?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="androidDevelopers" track-metadata-position="nav" track-metadata-eventdetail="nav"> <picture> <source srcset="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup-dark-theme.svg" media="(prefers-color-scheme: dark)" class="devsite-dark-theme" alt="Android Developers"> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup.svg" class="devsite-site-logo" alt="Android Developers"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list"> <li class="devsite-breadcrumb-item "></li> </ul></span> </div> </div> <div class="devsite-book-nav-wrapper"> <div class="devsite-mobile-nav-top"> <ul class="devsite-nav-list"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/get-started?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Essentials" track-name="essentials" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Essentials </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"><span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Essentials" track-name="essentials"> <span class="devsite-nav-text" tooltip menu="Essentials"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Essentials"> </span> </span></li> </ul></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Design & Plan" track-name="design & plan" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Design & Plan </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"><span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Design & Plan" track-name="design & plan"> <span class="devsite-nav-text" tooltip menu="Design & Plan"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Design & Plan"> </span> </span></li> </ul></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event devsite-nav-has-children devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: Develop" track-name="develop" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Develop </span> <span class="devsite-nav-icon material-icons" data-icon="forward"> </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"><span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Develop" track-name="develop"> <span class="devsite-nav-text" tooltip menu="Develop"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Develop"> </span> </span></li> </ul></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/distribute?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Google Play" track-name="google play" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Google Play </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/community?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" track-type="globalNav" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Community </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/studio?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android Studio" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android Studio </span> </a></li> </ul> </div> <div class="devsite-mobile-nav-bottom"> <ul class="devsite-nav-list" menu="_book"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/core-areas?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/core-areas" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/core-areas"><span class="devsite-nav-text" tooltip>All core areas ⍈</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work"><span class="devsite-nav-text" tooltip>About background work</span></a></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Services</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/services" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/services"><span class="devsite-nav-text" tooltip>About services</span></a></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Foreground services</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/services/foreground-services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/services/foreground-services" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/services/foreground-services"><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/services/fg-service-types?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/services/fg-service-types" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/services/fg-service-types"><span class="devsite-nav-text" tooltip>Foreground service types</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/services/fg-service-timeout?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/services/fg-service-timeout" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/services/fg-service-timeout"><span class="devsite-nav-text" tooltip>Foreground service timeout</span></a></li> </ul> </div></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/services/bound-services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/services/bound-services" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/services/bound-services"><span class="devsite-nav-text" tooltip>Bound services</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/services/aidl?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/services/aidl" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/services/aidl"><span class="devsite-nav-text" tooltip>About AIDL</span></a></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Background tasks</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks"><span class="devsite-nav-text" tooltip>About background tasks</span></a></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Keep the device awake</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/awake?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/awake" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/awake"><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/awake/wakelock?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/awake/wakelock" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/awake/wakelock"><span class="devsite-nav-text" tooltip>Set and manage wake locks</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/awake/screen-on?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/awake/screen-on" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/awake/screen-on"><span class="devsite-nav-text" tooltip>Keep the screen on</span></a></li> </ul> </div></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/optimize-battery?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/optimize-battery" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/optimize-battery"><span class="devsite-nav-text" tooltip>Optimize battery use for task scheduling APIs</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/bg-work-restrictions?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/bg-work-restrictions" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/bg-work-restrictions"><span class="devsite-nav-text" tooltip>System restrictions on background work</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/data-transfer-options?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/data-transfer-options" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/data-transfer-options"><span class="devsite-nav-text" tooltip>Data transfer background task options</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/uidt?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/uidt" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/uidt"><span class="devsite-nav-text" tooltip>User-initiated data transfer</span></a></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Asynchronous work</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/asynchronous?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/asynchronous" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/asynchronous"><span class="devsite-nav-text" tooltip>About async work</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/asynchronous/java-threads?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/asynchronous/java-threads" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/asynchronous/java-threads"><span class="devsite-nav-text" tooltip>Java threads</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/kotlin/coroutines?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /kotlin/coroutines" track-type="bookNav" track-name="click" track-metadata-eventdetail="/kotlin/coroutines"><span class="devsite-nav-text" tooltip>Coroutines ⍈</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/asynchronous/listenablefuture?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/asynchronous/listenablefuture" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/asynchronous/listenablefuture"><span class="devsite-nav-text" tooltip>Listenable future</span></a></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Persistent work</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent"><span class="devsite-nav-text" tooltip>About persistent work</span></a></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Getting started</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/getting-started?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/getting-started" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/getting-started"><span class="devsite-nav-text" tooltip>Getting started</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/getting-started/define-work?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/getting-started/define-work" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/getting-started/define-work"><span class="devsite-nav-text" tooltip>Define your work requests</span></a></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>How to</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/how-to/states?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/how-to/states" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/how-to/states"><span class="devsite-nav-text" tooltip>Work states</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/how-to/manage-work?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/how-to/manage-work" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/how-to/manage-work"><span class="devsite-nav-text" tooltip>Manage work</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/how-to/chain-work?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/how-to/chain-work" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/how-to/chain-work"><span class="devsite-nav-text" tooltip>Chain work together</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/how-to/long-running?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/how-to/long-running" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/how-to/long-running"><span class="devsite-nav-text" tooltip>Support for long-running workers</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/how-to/observe?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/how-to/observe" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/how-to/observe"><span class="devsite-nav-text" tooltip>Observe intermediate worker progress</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/how-to/update-work?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/how-to/update-work" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/how-to/update-work"><span class="devsite-nav-text" tooltip>Update work</span></a></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Threading</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/threading?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/threading" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/threading"><span class="devsite-nav-text" tooltip>About threading</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/threading/worker?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/threading/worker" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/threading/worker"><span class="devsite-nav-text" tooltip>Threading in Worker</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/threading/coroutineworker?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/threading/coroutineworker" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/threading/coroutineworker"><span class="devsite-nav-text" tooltip>Threading in CoRoutineWorker</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/threading/rxworker?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/threading/rxworker" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/threading/rxworker"><span class="devsite-nav-text" tooltip>Threading in RxWorker</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/threading/listenableworker?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/threading/listenableworker" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/threading/listenableworker"><span class="devsite-nav-text" tooltip>Threading in ListenableWorker</span></a></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Configuration</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/configuration/custom-configuration?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/configuration/custom-configuration" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/configuration/custom-configuration"><span class="devsite-nav-text" tooltip>Custom WorkManager configurations</span></a></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Migrate from legacy solutions</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/migrate-from-legacy/firebase?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/migrate-from-legacy/firebase" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/migrate-from-legacy/firebase"><span class="devsite-nav-text" tooltip>Migrate from Firebase JobDispatcher</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/persistent/migrate-from-legacy/gcm?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/persistent/migrate-from-legacy/gcm" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/persistent/migrate-from-legacy/gcm"><span class="devsite-nav-text" tooltip>Migrate from GCMNetworkManager</span></a></li> </ul> </div></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Testing</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Asynchronous work</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/kotlin/coroutines/test?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /kotlin/coroutines/test" track-type="bookNav" track-name="click" track-metadata-eventdetail="/kotlin/coroutines/test"><span class="devsite-nav-text" tooltip>Coroutines testing ⍈</span></a></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Persistent work</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/testing/persistent/debug?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/testing/persistent/debug" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/testing/persistent/debug"><span class="devsite-nav-text" tooltip>Debug WorkManager</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/testing/persistent/integration-testing?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/testing/persistent/integration-testing" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/testing/persistent/integration-testing"><span class="devsite-nav-text" tooltip>Integration testing</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/testing/persistent/worker-impl?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/testing/persistent/worker-impl" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/testing/persistent/worker-impl"><span class="devsite-nav-text" tooltip>Test worker implementation</span></a></li> </ul> </div></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Broadcasts</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/broadcasts?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/broadcasts" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/broadcasts"><span class="devsite-nav-text" tooltip>About broadcasts</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/background-tasks/broadcasts/broadcast-exceptions?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/background-tasks/broadcasts/broadcast-exceptions" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/background-tasks/broadcasts/broadcast-exceptions"><span class="devsite-nav-text" tooltip>Implicit Broadcast Exceptions</span></a></li> </ul> </div></li> </ul> </div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"> <div class="devsite-expandable-nav"><a class="devsite-nav-toggle" aria-hidden="true"></a> <div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"><span class="devsite-nav-text" tooltip>Alarms</span> </div> <ul class="devsite-nav-section"> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/services/alarms?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/services/alarms" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/services/alarms"><span class="devsite-nav-text" tooltip>About alarms</span></a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work/services/alarms/schedule?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /develop/background-work/services/alarms/schedule" track-type="bookNav" track-name="click" track-metadata-eventdetail="/develop/background-work/services/alarms/schedule"><span class="devsite-nav-text" tooltip>Schedule Alarms</span></a></li> </ul> </div></li> </ul> <ul class="devsite-nav-list" menu="Essentials" aria-label="Side menu" hidden> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Gemini in Android Studio </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/gemini-in-android?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Learn more" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Learn more </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/studio?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Get Android Studio" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Get Android Studio </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Get started </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/get-started/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Hello world" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Hello world </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/courses?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Training courses" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Training courses </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/get-started/codelabs?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Tutorials" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Tutorials </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/kotlin?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Kotlin for Android" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Kotlin for Android </span> </a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://play.google.com/console/about/guides/monetize/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Monetization with Play ↗️" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Monetization with Play ↗️ </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Extend by device </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/adaptive-apps?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Adaptive apps" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Adaptive apps </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/wear?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Wear OS" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Wear OS </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/cars?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android for Cars" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android for Cars </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/tv?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android TV" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android TV </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/chrome-os?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: ChromeOS" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> ChromeOS </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/multi-device-development?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Cross-device SDK" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Cross-device SDK </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Build by category </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/games?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Games" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Games </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/media?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Camera & Media" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Camera & Media </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/social-and-messaging?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Social & messaging" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Social & messaging </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/health-and-fitness?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Health & Fitness" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Health & Fitness </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/productivity?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Productivity" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Productivity </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/work/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Enterprise apps" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Enterprise apps </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Get the latest </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/latest-updates?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Latest updates" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Latest updates </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/latest-updates/experimental?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Experimental updates" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Experimental updates </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/studio/preview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android Studio preview" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android Studio preview </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/jetpack/androidx/versions?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Jetpack & Compose libraries" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Jetpack & Compose libraries </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/wearables/versions/4?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Wear OS preview" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Wear OS preview </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design-for-safety/privacy-sandbox?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Privacy Sandbox" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Privacy Sandbox </span> </a></li> </ul> <ul class="devsite-nav-list" menu="Design & Plan" aria-label="Side menu" hidden> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> UI Design </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Design for Android" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Design for Android </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/mobile?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Mobile" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Mobile </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/large-screens?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Large screens (e.g., tablets)" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Large screens (e.g., tablets) </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/widget?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Widgets" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Widgets </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/wear?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Wear OS" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Wear OS </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/design/ui/tv?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android TV" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android TV </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Architecture </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/topic/architecture/intro?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Introduction" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Introduction </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/topic/libraries/view-binding?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Libraries" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Libraries </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/navigation/navigation-principles?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Navigation" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Navigation </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/topic/modularization?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Modularization" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Modularization </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/testing/fundamentals?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Testing" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Testing </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Quality </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Overview" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Overview </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality/core-value?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Core value" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Core value </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality/user-experience?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: User experience" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> User experience </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality/technical?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Technical quality" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Technical quality </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quality/privacy-and-security?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Security" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Security </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Security </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/security?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Overview" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Overview </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/privacy-and-security/about?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Privacy" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Privacy </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/identity?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Identity" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Identity </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/security/fraud-prevention?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Fraud prevention" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Fraud prevention </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Build for Billions </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/build-for-billions?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Overview" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Overview </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/docs/quality-guidelines/build-for-billions?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: About new markets" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> About new markets </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/androidgo?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android (Go edition)" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android (Go edition) </span> </a></li> </ul> <ul class="devsite-nav-list" menu="Develop" aria-label="Side menu" hidden> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Build AI experiences </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/ai?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Get started" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Get started </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Core areas </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/samples?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Samples" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Samples </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/quick-guides?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Try Quick Guidesᵇᵉᵗᵃ" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Try Quick Guidesᵇᵉᵗᵃ </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/ui?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: User interfaces" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> User interfaces </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/permissions/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Permissions" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Permissions </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop/background-work?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Background work" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Background work </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/data?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Data and files" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Data and files </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/develop?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#core-areas" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: All core areas ⤵️" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> All core areas ⤵️ </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Tools and workflow </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/studio/write?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Write and debug code" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Write and debug code </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/build/gradle-build-overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Build projects" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Build projects </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/testing?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Test your app" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Test your app </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/topic/performance/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Performance" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Performance </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/tools?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Command-line tools" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Command-line tools </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/reference/tools/gradle-api?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Gradle plugin API" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Gradle plugin API </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Device tech </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/large-screens/get-started-with-large-screens?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Large screens (e.g., tablets)" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Large screens (e.g., tablets) </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/wearables?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Wear OS" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Wear OS </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/health-and-fitness/guides?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android Health" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android Health </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/guide/topics/connectivity/cross-device-sdk/overview?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Cross-device SDK" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Cross-device SDK </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/cars?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android for Cars" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android for Cars </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/training/tv?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android TV" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android TV </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/chrome-os/intro?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: ChromeOS" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> ChromeOS </span> </a></li> <li class="devsite-nav-item devsite-nav-heading"><span class="devsite-nav-title" tooltip> <span class="devsite-nav-text" tooltip> Libraries </span> </span></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/reference/packages?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android platform" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Android platform </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/jetpack/androidx/explorer?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Jetpack libraries" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Jetpack libraries </span> </a></li> <li class="devsite-nav-item"><a href="https://developer-android-com.translate.goog/jetpack/androidx/releases/compose?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Compose libraries" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Compose libraries </span> </a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://developers.google.com/android/reference/packages" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Google Play services ↗️" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Google Play services ↗️ </span> </a></li> <li class="devsite-nav-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://play.google.com/sdks" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Google Play SDK index ↗️" track-type="navMenu" track-metadata-eventdetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip> Google Play SDK index ↗️ </span> </a></li> </ul> </div> </div> </nav> </devsite-book-nav> <section id="gc-wrapper"> <main role="main" class="devsite-main-content" has-book-nav has-sidebar> <div class="devsite-sidebar"> <div class="devsite-sidebar-content"><devsite-toc class="devsite-nav" role="navigation" aria-label="On this page" depth="2" scrollbars></devsite-toc> <devsite-recommendations-sidebar class="nocontent devsite-nav"> </devsite-recommendations-sidebar> </div> </div><devsite-content> <article class="devsite-article"> <div class="devsite-article-meta nocontent" role="navigation"> <ul class="devsite-breadcrumb-list" aria-label="Breadcrumb"> <li class="devsite-breadcrumb-item "><a href="https://developer-android-com.translate.goog/?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="Android Developers"> Android Developers </a></li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div><a href="https://developer-android-com.translate.goog/develop?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="2" track-type="globalNav" track-name="breadcrumb" track-metadata-position="2" track-metadata-eventdetail="Develop"> Develop </a></li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div><a href="https://developer-android-com.translate.goog/develop/core-areas?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="3" track-type="globalNav" track-name="breadcrumb" track-metadata-position="3" track-metadata-eventdetail="Core areas"> Core areas </a></li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div><a href="https://developer-android-com.translate.goog/develop/background-work?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="4" track-type="globalNav" track-name="breadcrumb" track-metadata-position="4" track-metadata-eventdetail="Background work"> Background work </a></li> </ul><devsite-thumb-rating position="header"> </devsite-thumb-rating> </div> <h1 class="devsite-page-title" tabindex="-1">Services overview</h1><devsite-feature-tooltip ack-key="AckCollectionsBookmarkTooltipDismiss" analytics-category="Site-Wide Custom Events" analytics-action-show="Callout Profile displayed" analytics-action-close="Callout Profile dismissed" analytics-label="Create Collection Callout" class="devsite-page-bookmark-tooltip nocontent" dismiss-button="true" id="devsite-collections-dropdown" dismiss-button-text="Dismiss" close-button-text="Got it"> <devsite-bookmark></devsite-bookmark> <span slot="popout-heading"> Stay organized with collections </span> <span slot="popout-contents"> Save and categorize content based on your preferences. </span> </devsite-feature-tooltip> <div class="devsite-page-title-meta"> <devsite-view-release-notes></devsite-view-release-notes> </div><devsite-toc class="devsite-nav" depth="2" devsite-toc-embedded> </devsite-toc> <devsite-recommendations-dropdown class="nocontent"></devsite-recommendations-dropdown> <div class="devsite-article-body clearfix "> <p>A <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Service</a></code> is an <a href="https://developer-android-com.translate.goog/guide/components/fundamentals?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#Components">application component</a> that can perform long-running operations in the background. It does not provide a user interface. Once started, a service might continue running for some time, even after the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service can handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.</p> <p class="caution"><strong>Caution:</strong> A service runs in the main thread of its hosting process; the service does <strong>not</strong> create its own thread and does <strong>not</strong> run in a separate process unless you specify otherwise. You should run any blocking operations on a <a href="https://developer-android-com.translate.goog/training/multiple-threads?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">separate thread</a> within the service to avoid Application Not Responding (ANR) errors.</p> <h2 id="Types-of-services" data-text="Types of Services" tabindex="-1">Types of Services</h2> <p>These are the three different types of services:</p> <dl> <dt> Foreground </dt> <dd> <p>A foreground service performs some operation that is noticeable to the user. For example, an audio app would use a foreground service to play an audio track. Foreground services must display a <a href="https://developer-android-com.translate.goog/develop/ui/views/notifications?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Notification</a>. Foreground services continue running even when the user isn't interacting with the app.</p> <p>When you use a foreground service, you must display a notification so that users are actively aware that the service is running. This notification cannot be dismissed unless the service is either stopped or removed from the foreground.</p> <p>Learn more about how to configure <a href="https://developer-android-com.translate.goog/guide/components/foreground-services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">foreground services</a> in your app.</p> <p class="note"><strong>Note:</strong> The <a href="https://developer-android-com.translate.goog/topic/libraries/architecture/workmanager?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto"> WorkManager</a> API offers a flexible way of scheduling tasks, and is able to <a href="https://developer-android-com.translate.goog/topic/libraries/architecture/workmanager/advanced/long-running?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">run these jobs as foreground services</a> if needed. In many cases, using WorkManager is preferable to using foreground services directly.</p> </dd> <dt> Background </dt> <dd> A background service performs an operation that isn't directly noticed by the user. For example, if an app used a service to compact its storage, that would usually be a background service. <p class="note"><strong>Note:</strong> If your app targets API level 26 or higher, the system imposes <a href="https://developer-android-com.translate.goog/about/versions/oreo/background?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">restrictions on running background services</a> when the app itself isn't in the foreground. In most situations, for example, you shouldn't <a href="https://developer-android-com.translate.goog/training/location/background?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">access location information from the background</a>. Instead, <a href="https://developer-android-com.translate.goog/topic/libraries/architecture/workmanager?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">schedule tasks using WorkManager</a>.</p> </dd> <dt> Bound </dt> <dd> A service is <em>bound</em> when an application component binds to it by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code>. A bound service offers a client-server interface that allows components to interact with the service, send requests, receive results, and even do so across processes with interprocess communication (IPC). A bound service runs only as long as another application component is bound to it. Multiple components can bind to the service at once, but when all of them unbind, the service is destroyed. </dd> </dl> <p>Although this documentation generally discusses started and bound services separately, your service can work both ways—it can be started (to run indefinitely) and also allow binding. It's simply a matter of whether you implement a couple of callback methods: <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> to allow components to start it and <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onBind(android.content.Intent)">onBind()</a></code> to allow binding.</p> <p>Regardless of whether your service is started, bound, or both, any application component can use the service (even from a separate application) in the same way that any component can use an activity—by starting it with an <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Intent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Intent</a></code>. However, you can declare the service as <em>private</em> in the manifest file and block access from other applications. This is discussed more in the section about <a href="https://developer-android-com.translate.goog/develop/background-work/services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#Declaring">Declaring the service in the manifest</a>.</p> <h2 id="Choosing-service-thread" data-text="Choosing between a service and a thread" tabindex="-1">Choosing between a service and a thread</h2> <p>A service is simply a component that can run in the background, even when the user is not interacting with your application, so you should create a service only if that is what you need.</p> <p>If you must perform work outside of your main thread, but only while the user is interacting with your application, you should instead create a new thread in the context of another application component. For example, if you want to play some music, but only while your activity is running, you might create a thread in <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Activity?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onCreate(android.os.Bundle)">onCreate()</a></code>, start running it in <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Activity?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStart()">onStart()</a></code>, and stop it in <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Activity?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStop()">onStop()</a></code>. Also consider using thread pools and executors from the <code translate="no" dir="ltr">java.util.concurrent</code> package or <a href="https://developer-android-com.translate.goog/kotlin/coroutines?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Kotlin coroutines</a> instead of the traditional <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/java/lang/Thread?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Thread</a></code> class. See the <a href="https://developer-android-com.translate.goog/training/multiple-threads?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Threading on Android</a> document for more information about moving execution to background threads.</p> <p>Remember that if you do use a service, it still runs in your application's main thread by default, so you should still create a new thread within the service if it performs intensive or blocking operations.</p> <h2 id="Basics" data-text="The basics" tabindex="-1">The basics</h2> <p>To create a service, you must create a subclass of <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Service</a></code> or use one of its existing subclasses. In your implementation, you must override some callback methods that handle key aspects of the service lifecycle and provide a mechanism that allows the components to bind to the service, if appropriate. These are the most important callback methods that you should override:</p> <dl> <dt> <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> </dt> <dd> The system invokes this method by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> when another component (such as an activity) requests that the service be started. When this method executes, the service is started and can run in the background indefinitely. If you implement this, it is your responsibility to stop the service when its work is complete by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf()">stopSelf()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code>. If you only want to provide binding, you don't need to implement this method. </dd> <dt> <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onBind(android.content.Intent)">onBind()</a></code> </dt> <dd> The system invokes this method by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code> when another component wants to bind with the service (such as to perform RPC). In your implementation of this method, you must provide an interface that clients use to communicate with the service by returning an <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/os/IBinder?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">IBinder</a></code>. You must always implement this method; however, if you don't want to allow binding, you should return null. </dd> <dt> <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onCreate()">onCreate()</a></code> </dt> <dd> The system invokes this method to perform one-time setup procedures when the service is initially created (before it calls either <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onBind(android.content.Intent)">onBind()</a></code>). If the service is already running, this method is not called. </dd> <dt> <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onDestroy()">onDestroy()</a></code> </dt> <dd> The system invokes this method when the service is no longer used and is being destroyed. Your service should implement this to clean up any resources such as threads, registered listeners, or receivers. This is the last call that the service receives. </dd> </dl> <p>If a component starts the service by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> (which results in a call to <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code>), the service continues to run until it stops itself with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf()">stopSelf()</a></code> or another component stops it by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code>.</p> <p>If a component calls <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code> to create the service and <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> is <em>not</em> called, the service runs only as long as the component is bound to it. After the service is unbound from all of its clients, the system destroys it.</p> <p>The Android system stops a service only when memory is low and it must recover system resources for the activity that has user focus. If the service is bound to an activity that has user focus, it's less likely to be killed; if the service is declared to <a href="https://developer-android-com.translate.goog/guide/components/foreground-services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">run in the foreground</a>, it's rarely killed. If the service is started and is long-running, the system lowers its position in the list of background tasks over time, and the service becomes highly susceptible to killing—if your service is started, you must design it to gracefully handle restarts by the system. If the system kills your service, it restarts it as soon as resources become available, but this also depends on the value that you return from <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code>. For more information about when the system might destroy a service, see the <a href="https://developer-android-com.translate.goog/guide/components/processes-and-threads?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Processes and Threading</a> document.</p> <p>In the following sections, you'll see how you can create the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> and <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code> service methods, as well as how to use them from other application components.</p> <h3 id="Declaring" data-text="Declaring a service in the manifest" tabindex="-1">Declaring a service in the manifest</h3> <p>You must declare all services in your application's manifest file, just as you do for activities and other components.</p> <p>To declare your service, add a <a href="https://developer-android-com.translate.goog/guide/topics/manifest/service-element?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto"><code translate="no" dir="ltr"><service></code></a> element as a child of the <a href="https://developer-android-com.translate.goog/guide/topics/manifest/application-element?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto"><code translate="no" dir="ltr"><application></code></a> element. Here is an example:</p> <pre class="prettyprint lang-xml" translate="no" dir="ltr"><manifest ... > ... <application ... > <service android:name=".ExampleService" /> ... </application> </manifest> </pre> <p>See the <a href="https://developer-android-com.translate.goog/guide/topics/manifest/service-element?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto"><code translate="no" dir="ltr"><service></code></a> element reference for more information about declaring your service in the manifest.</p> <p>There are other attributes that you can include in the <a href="https://developer-android-com.translate.goog/guide/topics/manifest/service-element?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto"><code translate="no" dir="ltr"><service></code></a> element to define properties such as the permissions that are required to start the service and the process in which the service should run. The <a href="https://developer-android-com.translate.goog/guide/topics/manifest/service-element?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#nm"><code translate="no" dir="ltr">android:name</code></a> attribute is the only required attribute—it specifies the class name of the service. After you publish your application, leave this name unchanged to avoid the risk of breaking code due to dependence on explicit intents to start or bind the service (read the blog post, <a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=http://android-developers.blogspot.com/2011/06/things-that-cannot-change.html">Things That Cannot Change</a>).</p> <p class="caution"><strong>Caution</strong>: To ensure that your app is secure, always use an explicit intent when starting a <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Service</a></code> and don't declare intent filters for your services. Using an implicit intent to start a service is a security hazard because you cannot be certain of the service that responds to the intent, and the user cannot see which service starts. Beginning with Android 5.0 (API level 21), the system throws an exception if you call <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code> with an implicit intent.</p> <p>You can ensure that your service is available to only your app by including the <a href="https://developer-android-com.translate.goog/guide/topics/manifest/service-element?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#exported"><code translate="no" dir="ltr">android:exported</code></a> attribute and setting it to <code translate="no" dir="ltr">false</code>. This effectively stops other apps from starting your service, even when using an explicit intent.</p> <p class="note"><strong>Note</strong>: Users can see what services are running on their device. If they see a service that they don't recognize or trust, they can stop the service. In order to avoid having your service stopped accidentally by users, you need to add the <a href="https://developer-android-com.translate.goog/guide/topics/manifest/service-element?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#desc"><code translate="no" dir="ltr">android:description</code></a> attribute to the <a href="https://developer-android-com.translate.goog/guide/topics/manifest/service-element?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto"><code translate="no" dir="ltr"><service></code></a> element in your app manifest. In the description, provide a short sentence explaining what the service does and what benefits it provides.</p> <h2 id="CreatingAService" data-text="Creating a started service" tabindex="-1">Creating a started service</h2> <p>A started service is one that another component starts by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code>, which results in a call to the service's <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> method.</p> <p>When a service is started, it has a lifecycle that's independent of the component that started it. The service can run in the background indefinitely, even if the component that started it is destroyed. As such, the service should stop itself when its job is complete by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf()">stopSelf()</a></code>, or another component can stop it by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code>.</p> <p>An application component such as an activity can start the service by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> and passing an <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Intent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Intent</a></code> that specifies the service and includes any data for the service to use. The service receives this <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Intent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Intent</a></code> in the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> method.</p> <p>For instance, suppose an activity needs to save some data to an online database. The activity can start a companion service and deliver it the data to save by passing an intent to <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code>. The service receives the intent in <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code>, connects to the Internet, and performs the database transaction. When the transaction is complete, the service stops itself and is destroyed.</p> <p class="caution"><strong>Caution:</strong> A service runs in the same process as the application in which it is declared and in the main thread of that application by default. If your service performs intensive or blocking operations while the user interacts with an activity from the same application, the service slows down activity performance. To avoid impacting application performance, start a new thread inside the service.</p> <p>The <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Service</a></code> class is the base class for all services. When you extend this class, it's important to create a new thread in which the service can complete all of its work; the service uses your application's main thread by default, which can slow the performance of any activity that your application is running.</p> <p>The Android framework also provides the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/IntentService?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">IntentService</a></code> subclass of <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Service</a></code> that uses a worker thread to handle all of the start requests, one at a time. Using this class is <strong>not recommended</strong> for new apps as it will not work well starting with Android 8 Oreo, due to the introduction of <a href="https://developer-android-com.translate.goog/about/versions/oreo/background?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#services">Background execution limits</a>. Moreover, it's deprecated starting with Android 11. You can use <a href="https://developer-android-com.translate.goog/reference/androidx/core/app/JobIntentService?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">JobIntentService</a> as a replacement for <code translate="no" dir="ltr">IntentService</code> that is compatible with newer versions of Android.</p> <p>The following sections describe how you can implement your own custom service, however you should strongly consider using WorkManager instead for most use cases. Consult the <a href="https://developer-android-com.translate.goog/guide/background?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">guide to background processing on Android</a> to see if there is a solution that fits your needs.</p> <h3 id="ExtendingService" data-text="Extending the Service class" tabindex="-1">Extending the Service class</h3> <p>You can extend the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Service</a></code> class to handle each incoming intent. Here's how a basic implementation might look:</p> <div> <div class="ds-selector-tabs"> <section> <h3 id="kotlin" data-text="Kotlin" tabindex="-1">Kotlin</h3> <pre class="prettyprint lang-kotlin" translate="no" dir="ltr">class HelloService : Service() { private var serviceLooper: Looper? = null private var serviceHandler: ServiceHandler? = null // Handler that receives messages from the thread private inner class ServiceHandler(looper: Looper) : Handler(looper) { override fun handleMessage(msg: Message) { // Normally we would do some work here, like download a file. // For our sample, we just sleep for 5 seconds. try { Thread.sleep(5000) } catch (e: InterruptedException) { // Restore interrupt status. Thread.currentThread().interrupt() } // Stop the service using the startId, so that we don't stop // the service in the middle of handling another job stopSelf(msg.arg1) } } override fun onCreate() { // Start up the thread running the service. Note that we create a // separate thread because the service normally runs in the process's // main thread, which we don't want to block. We also make it // background priority so CPU-intensive work will not disrupt our UI. HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND).apply { start() // Get the HandlerThread's Looper and use it for our Handler serviceLooper = looper serviceHandler = ServiceHandler(looper) } } override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show() // For each start request, send a message to start a job and deliver the // start ID so we know which request we're stopping when we finish the job serviceHandler?.obtainMessage()?.also { msg -> msg.arg1 = startId serviceHandler?.sendMessage(msg) } // If we get killed, after returning from here, restart return START_STICKY } override fun onBind(intent: Intent): IBinder? { // We don't provide binding, so return null return null } override fun onDestroy() { Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show() } } </pre> </section> <section> <h3 id="java" data-text="Java" tabindex="-1">Java</h3> <pre class="prettyprint lang-java" translate="no" dir="ltr">public class HelloService extends Service { private Looper serviceLooper; private ServiceHandler serviceHandler; // Handler that receives messages from the thread private final class ServiceHandler extends Handler { public ServiceHandler(Looper looper) { super(looper); } @Override public void handleMessage(Message msg) { // Normally we would do some work here, like download a file. // For our sample, we just sleep for 5 seconds. try { Thread.sleep(5000); } catch (InterruptedException e) { // Restore interrupt status. Thread.currentThread().interrupt(); } // Stop the service using the startId, so that we don't stop // the service in the middle of handling another job stopSelf(msg.arg1); } } @Override public void onCreate() { // Start up the thread running the service. Note that we create a // separate thread because the service normally runs in the process's // main thread, which we don't want to block. We also make it // background priority so CPU-intensive work doesn't disrupt our UI. HandlerThread thread = new HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND); thread.start(); // Get the HandlerThread's Looper and use it for our Handler serviceLooper = thread.getLooper(); serviceHandler = new ServiceHandler(serviceLooper); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show(); // For each start request, send a message to start a job and deliver the // start ID so we know which request we're stopping when we finish the job Message msg = serviceHandler.obtainMessage(); msg.arg1 = startId; serviceHandler.sendMessage(msg); // If we get killed, after returning from here, restart return START_STICKY; } @Override public IBinder onBind(Intent intent) { // We don't provide binding, so return null return null; } @Override public void onDestroy() { Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show(); } } </pre> </section> </div> </div> <p>The example code handles all incoming calls in <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> and posts the work to a <code translate="no" dir="ltr">Handler</code> running on a background thread. It works just like an <code translate="no" dir="ltr">IntentService</code> and processes all requests serially, one after another. You could change the code to run the work on a thread pool, for example, if you'd like to run multiple requests simultaneously.</p> <p>Notice that the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> method must return an integer. The integer is a value that describes how the system should continue the service in the event that the system kills it. The return value from <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> must be one of the following constants:</p> <dl> <dt> <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#START_NOT_STICKY">START_NOT_STICKY</a></code> </dt> <dd> If the system kills the service after <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> returns, <em>do not</em> recreate the service unless there are pending intents to deliver. This is the safest option to avoid running your service when not necessary and when your application can simply restart any unfinished jobs. </dd> <dt> <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#START_STICKY">START_STICKY</a></code> </dt> <dd> If the system kills the service after <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> returns, recreate the service and call <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code>, but <em>do not</em> redeliver the last intent. Instead, the system calls <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> with a null intent unless there are pending intents to start the service. In that case, those intents are delivered. This is suitable for media players (or similar services) that are not executing commands but are running indefinitely and waiting for a job. </dd> <dt> <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#START_REDELIVER_INTENT">START_REDELIVER_INTENT</a></code> </dt> <dd> If the system kills the service after <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> returns, recreate the service and call <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> with the last intent that was delivered to the service. Any pending intents are delivered in turn. This is suitable for services that are actively performing a job that should be immediately resumed, such as downloading a file. </dd> </dl> <p>For more details about these return values, see the linked reference documentation for each constant.</p> <h3 id="StartingAService" data-text="Starting a service" tabindex="-1">Starting a service</h3> <p>You can start a service from an activity or other application component by passing an <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Intent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Intent</a></code> to <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startForegroundService(android.content.Intent)">startForegroundService()</a></code>. The Android system calls the service's <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> method and passes it the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Intent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Intent</a></code>, which specifies which service to start.</p> <p class="note"><strong>Note</strong>: If your app targets API level 26 or higher, the system imposes restrictions on using or creating background services unless the app itself is in the foreground. If an app needs to create a foreground service, the app should call <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startForegroundService(android.content.Intent)">startForegroundService()</a></code>. That method creates a background service, but the method signals to the system that the service will promote itself to the foreground. Once the service has been created, the service must call its <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startForeground(int, android.app.Notification)">startForeground()</a></code> method within five seconds.</p> <p>For example, an activity can start the example service in the previous section (<code translate="no" dir="ltr">HelloService</code>) using an explicit intent with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code>, as shown here:</p> <div> <div class="ds-selector-tabs"> <section> <h3 id="kotlin" data-text="Kotlin" tabindex="-1">Kotlin</h3> <pre class="prettyprint lang-kotlin" translate="no" dir="ltr">startService(Intent(this, HelloService::class.java)) </pre> </section> <section> <h3 id="java" data-text="Java" tabindex="-1">Java</h3> <pre class="prettyprint lang-java" translate="no" dir="ltr">startService(new Intent(this, HelloService.class)); </pre> </section> </div> </div> <p>The <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> method returns immediately, and the Android system calls the service's <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> method. If the service isn't already running, the system first calls <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onCreate()">onCreate()</a></code>, and then it calls <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code>.</p> <p>If the service doesn't also provide binding, the intent that is delivered with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> is the only mode of communication between the application component and the service. However, if you want the service to send a result back, the client that starts the service can create a <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/PendingIntent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">PendingIntent</a></code> for a broadcast (with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/PendingIntent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#getBroadcast(android.content.Context, int, android.content.Intent, int)">getBroadcast()</a></code>) and deliver it to the service in the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Intent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Intent</a></code> that starts the service. The service can then use the broadcast to deliver a result.</p> <p>Multiple requests to start the service result in multiple corresponding calls to the service's <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code>. However, only one request to stop the service (with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf()">stopSelf()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code>) is required to stop it.</p> <h3 id="Stopping" data-text="Stopping a service" tabindex="-1">Stopping a service</h3> <p>A started service must manage its own lifecycle. That is, the system doesn't stop or destroy the service unless it must recover system memory and the service continues to run after <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> returns. The service must stop itself by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf()">stopSelf()</a></code>, or another component can stop it by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code>.</p> <p>Once requested to stop with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf()">stopSelf()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code>, the system destroys the service as soon as possible.</p> <p>If your service handles multiple requests to <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> concurrently, you shouldn't stop the service when you're done processing a start request, as you might have received a new start request (stopping at the end of the first request would terminate the second one). To avoid this problem, you can use <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf(int)">stopSelf(int)</a></code> to ensure that your request to stop the service is always based on the most recent start request. That is, when you call <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf(int)">stopSelf(int)</a></code>, you pass the ID of the start request (the <code translate="no" dir="ltr">startId</code> delivered to <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code>) to which your stop request corresponds. Then, if the service receives a new start request before you are able to call <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf(int)">stopSelf(int)</a></code>, the ID doesn't match and the service doesn't stop.</p> <p class="caution"><strong>Caution:</strong> To avoid wasting system resources and consuming battery power, ensure that your application stops its services when it's done working. If necessary, other components can stop the service by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code>. Even if you enable binding for the service, you must always stop the service yourself if it ever receives a call to <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code>.</p> <p>For more information about the lifecycle of a service, see the section below about <a href="https://developer-android-com.translate.goog/develop/background-work/services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#Lifecycle">Managing the Lifecycle of a Service</a>.</p> <h2 id="CreatingBoundService" data-text="Creating a bound service" tabindex="-1">Creating a bound service</h2> <p>A bound service is one that allows application components to bind to it by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code> to create a long-standing connection. It generally doesn't allow components to <em>start</em> it by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code>.</p> <p>Create a bound service when you want to interact with the service from activities and other components in your application or to expose some of your application's functionality to other applications through interprocess communication (IPC).</p> <p>To create a bound service, implement the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onBind(android.content.Intent)">onBind()</a></code> callback method to return an <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/os/IBinder?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">IBinder</a></code> that defines the interface for communication with the service. Other application components can then call <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code> to retrieve the interface and begin calling methods on the service. The service lives only to serve the application component that is bound to it, so when there are no components bound to the service, the system destroys it. You do <em>not</em> need to stop a bound service in the same way that you must when the service is started through <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code>.</p> <p>To create a bound service, you must define the interface that specifies how a client can communicate with the service. This interface between the service and a client must be an implementation of <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/os/IBinder?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">IBinder</a></code> and is what your service must return from the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onBind(android.content.Intent)">onBind()</a></code> callback method. After the client receives the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/os/IBinder?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">IBinder</a></code>, it can begin interacting with the service through that interface.</p> <p>Multiple clients can bind to the service simultaneously. When a client is done interacting with the service, it calls <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#unbindService(android.content.ServiceConnection)">unbindService()</a></code> to unbind. When there are no clients bound to the service, the system destroys the service.</p> <p>There are multiple ways to implement a bound service, and the implementation is more complicated than a started service. For these reasons, the bound service discussion appears in a separate document about <a href="https://developer-android-com.translate.goog/guide/components/bound-services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Bound Services</a>.</p> <h2 id="Notifications" data-text="Sending notifications to the user" tabindex="-1">Sending notifications to the user</h2> <p>When a service is running, it can notify the user of events using <a href="https://developer-android-com.translate.goog/develop/ui/views/notifications/snackbar?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">snackbar notifications</a> or <a href="https://developer-android-com.translate.goog/develop/ui/views/notifications/build-notification?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">status bar notifications</a>.</p> <p>A snackbar notification is a message that appears on the surface of the current window for only a moment before disappearing. A status bar notification provides an icon in the status bar with a message, which the user can select in order to take an action (such as start an activity).</p> <p>Usually, a status bar notification is the best technique to use when background work such as a file download has completed, and the user can now act on it. When the user selects the notification from the expanded view, the notification can start an activity (such as to display the downloaded file).</p> <h2 id="Lifecycle" data-text="Managing the lifecycle of a service" tabindex="-1">Managing the lifecycle of a service</h2> <p>The lifecycle of a service is much simpler than that of an activity. However, it's even more important that you pay close attention to how your service is created and destroyed because a service can run in the background without the user being aware.</p> <p>The service lifecycle—from when it's created to when it's destroyed—can follow either of these two paths:</p> <ul> <li>A started service <p>The service is created when another component calls <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code>. The service then runs indefinitely and must stop itself by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf()">stopSelf()</a></code>. Another component can also stop the service by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code>. When the service is stopped, the system destroys it.</p></li> <li>A bound service <p>The service is created when another component (a client) calls <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code>. The client then communicates with the service through an <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/os/IBinder?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">IBinder</a></code> interface. The client can close the connection by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#unbindService(android.content.ServiceConnection)">unbindService()</a></code>. Multiple clients can bind to the same service and when all of them unbind, the system destroys the service. The service does <em>not</em> need to stop itself.</p></li> </ul> <p>These two paths aren't entirely separate. You can bind to a service that is already started with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code>. For example, you can start a background music service by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> with an <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Intent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Intent</a></code> that identifies the music to play. Later, possibly when the user wants to exercise some control over the player or get information about the current song, an activity can bind to the service by calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code>. In cases such as this, <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf()">stopSelf()</a></code> doesn't actually stop the service until all of the clients unbind.</p> <h3 id="LifecycleCallbacks" data-text="Implementing the lifecycle callbacks" tabindex="-1">Implementing the lifecycle callbacks</h3> <p>Like an activity, a service has lifecycle callback methods that you can implement to monitor changes in the service's state and perform work at the appropriate times. The following skeleton service demonstrates each of the lifecycle methods:</p> <div> <div class="ds-selector-tabs"> <section> <h3 id="kotlin" data-text="Kotlin" tabindex="-1">Kotlin</h3> <pre class="prettyprint lang-kotlin" translate="no" dir="ltr">class ExampleService : Service() { private var startMode: Int = 0 // indicates how to behave if the service is killed private var binder: IBinder? = null // interface for clients that bind private var allowRebind: Boolean = false // indicates whether onRebind should be used override fun <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onCreate()">onCreate</a></code>() { // The service is being created } override fun <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand</a></code>(intent: Intent?, flags: Int, startId: Int): Int { // The service is starting, due to a call to startService() return <em>startMode</em> } override fun <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onBind(android.content.Intent)">onBind</a></code>(intent: Intent): IBinder? { // A client is binding to the service with bindService() return <em>binder</em> } override fun <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onUnbind(android.content.Intent)">onUnbind</a></code>(intent: Intent): Boolean { // All clients have unbound with unbindService() return <em>allowRebind</em> } override fun <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onRebind(android.content.Intent)">onRebind</a></code>(intent: Intent) { // A client is binding to the service with bindService(), // after onUnbind() has already been called } override fun <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onDestroy()">onDestroy</a></code>() { // The service is no longer used and is being destroyed } } </pre> </section> <section> <h3 id="java" data-text="Java" tabindex="-1">Java</h3> <pre class="prettyprint lang-java" translate="no" dir="ltr">public class ExampleService extends Service { int startMode; // indicates how to behave if the service is killed IBinder binder; // interface for clients that bind boolean allowRebind; // indicates whether onRebind should be used @Override public void <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onCreate()">onCreate</a></code>() { // The service is being created } @Override public int <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand</a></code>(Intent intent, int flags, int startId) { // The service is starting, due to a call to <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> return <em>startMode</em>; } @Override public IBinder <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onBind(android.content.Intent)">onBind</a></code>(Intent intent) { // A client is binding to the service with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code> return <em>binder</em>; } @Override public boolean <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onUnbind(android.content.Intent)">onUnbind</a></code>(Intent intent) { // All clients have unbound with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#unbindService(android.content.ServiceConnection)">unbindService()</a></code> return <em>allowRebind</em>; } @Override public void <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onRebind(android.content.Intent)">onRebind</a></code>(Intent intent) { // A client is binding to the service with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code>, // after onUnbind() has already been called } @Override public void <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onDestroy()">onDestroy</a></code>() { // The service is no longer used and is being destroyed } } </pre> </section> </div> </div> <p class="note"><strong>Note:</strong> Unlike the activity lifecycle callback methods, you are <em>not</em> required to call the superclass implementation of these callback methods.</p><img src="/static/images/service_lifecycle.png" alt class="android-image-dark-theme-background"> <p class="img-caption"><strong>Figure 2.</strong> The service lifecycle. The diagram on the left shows the lifecycle when the service is created with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> and the diagram on the right shows the lifecycle when the service is created with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code>.</p> <p>Figure 2 illustrates the typical callback methods for a service. Although the figure separates services that are created by <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> from those created by <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code>, keep in mind that any service, no matter how it's started, can potentially allow clients to bind to it. A service that was initially started with <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> (by a client calling <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code>) can still receive a call to <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onBind(android.content.Intent)">onBind()</a></code> (when a client calls <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code>).</p> <p>By implementing these methods, you can monitor these two nested loops of the service's lifecycle:</p> <ul> <li>The <strong>entire lifetime</strong> of a service occurs between the time that <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onCreate()">onCreate()</a></code> is called and the time that <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onDestroy()">onDestroy()</a></code> returns. Like an activity, a service does its initial setup in <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onCreate()">onCreate()</a></code> and releases all remaining resources in <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onDestroy()">onDestroy()</a></code>. For example, a music playback service can create the thread where the music is played in <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onCreate()">onCreate()</a></code>, and then it can stop the thread in <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onDestroy()">onDestroy()</a></code>. <p class="note"><strong>Note</strong>: The <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onCreate()">onCreate()</a></code> and <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onDestroy()">onDestroy()</a></code> methods are called for all services, whether they're created by <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code>.</p></li> <li>The <strong>active lifetime</strong> of a service begins with a call to either <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onBind(android.content.Intent)">onBind()</a></code>. Each method is handed the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Intent?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Intent</a></code> that was passed to either <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#startService(android.content.Intent)">startService()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#bindService(android.content.Intent, android.content.ServiceConnection, int)">bindService()</a></code>. <p>If the service is started, the active lifetime ends at the same time that the entire lifetime ends (the service is still active even after <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onStartCommand(android.content.Intent, int, int)">onStartCommand()</a></code> returns). If the service is bound, the active lifetime ends when <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onUnbind(android.content.Intent)">onUnbind()</a></code> returns.</p></li> </ul> <p class="note"><strong>Note:</strong> Although a started service is stopped by a call to either <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopSelf()">stopSelf()</a></code> or <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/content/Context?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#stopService(android.content.Intent)">stopService()</a></code>, there isn't a respective callback for the service (there's no <code translate="no" dir="ltr">onStop()</code> callback). Unless the service is bound to a client, the system destroys it when the service is stopped—<code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onDestroy()">onDestroy()</a></code> is the only callback received.</p> <p>For more information about creating a service that provides binding, see the <a href="https://developer-android-com.translate.goog/guide/components/bound-services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Bound Services</a> document, which includes more information about the <code translate="no" dir="ltr"><a href="https://developer-android-com.translate.goog/reference/android/app/Service?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#onRebind(android.content.Intent)">onRebind()</a></code> callback method in the section about <a href="https://developer-android-com.translate.goog/guide/components/bound-services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#Lifecycle">Managing the lifecycle of a bound service</a>.</p><!-- <h2 id="beginners-path" data-text="Beginner's Path" tabindex="-1">Beginner's Path</h2> <p>To learn how to query data from the system or other applications (such as contacts or media stored on the device), continue with the <b><a href="/guide/topics/providers/content-providers">Content Providers</a></b> document.</p> --> <devsite-hats-survey class="nocontent" hats-id="onAFgYxTD0kxBYCLVTd0Z41p75CM" listnr-id="5207477"></devsite-hats-survey> </div><devsite-recommendations display="in-page" hidden yield> </devsite-recommendations> <devsite-thumb-rating position="footer"> </devsite-thumb-rating> <devsite-recommendations id="recommendations-link" yield></devsite-recommendations> <div class="devsite-floating-action-buttons"> </div> </article> <devsite-content-footer class="nocontent"> <p>Content and code samples on this page are subject to the licenses described in the <a href="https://developer-android-com.translate.goog/license?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto">Content License</a>. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.</p> <p>Last updated 2024-03-27 UTC.</p> </devsite-content-footer> <devsite-notification> </devsite-notification> <div class="devsite-content-data"> <template class="devsite-content-data-template"> [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-03-27 UTC."],[],[]] </template> </div> </devsite-content> </main><devsite-footer-promos class="devsite-footer"> <nav class="devsite-footer-promos nocontent" aria-label="Promotions"> <ul class="devsite-footer-promos-list"> <li class="devsite-footer-promo"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://x.com/AndroidDev" class="devsite-footer-promo-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer X Promo"> <picture> <source class="devsite-dark-theme" srcset="https://developer-android-com.translate.goog/_static/android/images/logo-x_dt.svg?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" media="(prefers-color-scheme: dark)" loading="lazy" alt="X"> <img class="devsite-footer-promo-icon" src="/_static/android/images/logo-x.svg" loading="lazy" alt="X"> </picture> <span class="devsite-footer-promo-label"> X </span> </a> <div class="devsite-footer-promo-description"> Follow @AndroidDev on X </div></li> <li class="devsite-footer-promo"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://www.youtube.com/user/androiddevelopers" class="devsite-footer-promo-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer YouTube Promo"> <picture> <source class="devsite-dark-theme" srcset="https://developer-android-com.translate.goog/_static/android/images/logo-youtube_dt.svg?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" media="(prefers-color-scheme: dark)" loading="lazy" alt="YouTube"> <img class="devsite-footer-promo-icon" src="//www.gstatic.com/images/icons/material/product/2x/youtube_48dp.png" loading="lazy" alt="YouTube"> </picture> <span class="devsite-footer-promo-label"> YouTube </span> </a> <div class="devsite-footer-promo-description"> Check out Android Developers on YouTube </div></li> <li class="devsite-footer-promo"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://www.linkedin.com/showcase/androiddev" class="devsite-footer-promo-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer LinkedIn Promo"> <picture> <source class="devsite-dark-theme" srcset="https://developer-android-com.translate.goog/_static/android/images/logo-linkedin_dt.svg?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" media="(prefers-color-scheme: dark)" loading="lazy" alt="LinkedIn"> <img class="devsite-footer-promo-icon" src="/_static/android/images/logo-linkedin.svg" loading="lazy" alt="LinkedIn"> </picture> <span class="devsite-footer-promo-label"> LinkedIn </span> </a> <div class="devsite-footer-promo-description"> Connect with the Android Developers community on LinkedIn </div></li> </ul> </nav> </devsite-footer-promos> <devsite-footer-linkboxes class="devsite-footer"> <nav class="devsite-footer-linkboxes nocontent" aria-label="Footer links"> <ul class="devsite-footer-linkboxes-list"> <li class="devsite-footer-linkbox "><h3 class="devsite-footer-linkbox-heading no-link">More Android</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://www.android.com" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)"> Android </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://www.android.com/enterprise/" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)"> Android for Enterprise </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://www.android.com/security-center/" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)"> Security </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://source.android.com" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)"> Source </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/news?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)"> News </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://android-developers.googleblog.com/" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 6)"> Blog </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/podcasts?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 7)"> Podcasts </a></li> </ul></li> <li class="devsite-footer-linkbox "><h3 class="devsite-footer-linkbox-heading no-link">Discover</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/games?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)"> Gaming </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/ml?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)"> Machine Learning </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/health-and-fitness?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)"> Health & Fitness </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/media?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)"> Camera & Media </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/privacy?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)"> Privacy </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/training/connectivity/5g?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 6)"> 5G </a></li> </ul></li> <li class="devsite-footer-linkbox "><h3 class="devsite-footer-linkbox-heading no-link">Android Devices</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/large-screens?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)"> Large screens </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/wear?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)"> Wear OS </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/chrome-os?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)"> ChromeOS devices </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/cars?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)"> Android for cars </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/tv?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)"> Android TV </a></li> </ul></li> <li class="devsite-footer-linkbox "><h3 class="devsite-footer-linkbox-heading no-link">Releases</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/about/versions/15?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)"> Android 15 </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/about/versions/14?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)"> Android 14 </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/about/versions/13?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)"> Android 13 </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/about/versions/12?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)"> Android 12 </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/about/versions/11?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)"> Android 11 </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/about/versions/10?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 6)"> Android 10 </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/about/versions/pie?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 7)"> Pie </a></li> </ul></li> <li class="devsite-footer-linkbox "><h3 class="devsite-footer-linkbox-heading no-link">Documentation and Downloads</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/studio/intro?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)"> Android Studio guide </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/guide?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)"> Developers guides </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/reference?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)"> API reference </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/studio?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)"> Download Studio </a></li> <li class="devsite-footer-linkbox-item"><a href="https://developer-android-com.translate.goog/ndk?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)"> Android NDK </a></li> </ul></li> <li class="devsite-footer-linkbox "><h3 class="devsite-footer-linkbox-heading no-link">Support</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://issuetracker.google.com/issues/new?component%3D190923%26template%3D841312" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)"> Report platform bug </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://issuetracker.google.com/issues/new?component%3D192697" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)"> Report documentation bug </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://support.google.com/googleplay/android-developer" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)"> Google Play support </a></li> <li class="devsite-footer-linkbox-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://g.co/userresearch/androiddeveloperfooter" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)"> Join research studies </a></li> </ul></li> </ul> </nav> </devsite-footer-linkboxes> <devsite-footer-utility class="devsite-footer"> <div class="devsite-footer-utility nocontent"> <nav class="devsite-footer-sites" aria-label="Other Google Developers websites"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://developers.google.com/" class="devsite-footer-sites-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Google Developers Link"> <picture> <source srcset="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup-google-for-developers-dark-theme.svg" media="(prefers-color-scheme: none)" class="devsite-dark-theme" loading="lazy" alt="Google Developers"> <img class="devsite-footer-sites-logo" src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup-google-for-developers.svg" loading="lazy" alt="Google Developers"> </picture> </a> <ul class="devsite-footer-sites-list"> <li class="devsite-footer-sites-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://developer.android.com" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Android Link"> Android </a></li> <li class="devsite-footer-sites-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://developer.chrome.com/home" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Chrome Link"> Chrome </a></li> <li class="devsite-footer-sites-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://firebase.google.com" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Firebase Link"> Firebase </a></li> <li class="devsite-footer-sites-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://cloud.google.com" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Google Cloud Platform Link"> Google Cloud Platform </a></li> <li class="devsite-footer-sites-item"><a href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://developers.google.com/products/" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer All products Link"> All products </a></li> </ul> </nav> <nav class="devsite-footer-utility-links" aria-label="Utility links"> <ul class="devsite-footer-utility-list"> <li class="devsite-footer-utility-item "><a class="devsite-footer-utility-link gc-analytics-event" href="https://translate.google.com/website?sl=auto&tl=en&hl=auto&u=https://policies.google.com/privacy" data-category="Site-Wide Custom Events" data-label="Footer Privacy link"> Privacy </a></li> <li class="devsite-footer-utility-item "><a class="devsite-footer-utility-link gc-analytics-event" href="https://developer-android-com.translate.goog/license?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" data-category="Site-Wide Custom Events" data-label="Footer License link"> License </a></li> <li class="devsite-footer-utility-item "><a class="devsite-footer-utility-link gc-analytics-event" href="https://developer-android-com.translate.goog/distribute/marketing-tools/brand-guidelines?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" data-category="Site-Wide Custom Events" data-label="Footer Brand guidelines link"> Brand guidelines </a></li> <li class="devsite-footer-utility-item glue-cookie-notification-bar-control"><a class="devsite-footer-utility-link gc-analytics-event" href="https://developer-android-com.translate.goog/develop/background-work/services?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto#" data-category="Site-Wide Custom Events" data-label="Footer Manage cookies link" aria-hidden="true"> Manage cookies </a></li> <li class="devsite-footer-utility-item devsite-footer-utility-button"><span class="devsite-footer-utility-description">Get news and tips by email</span> <a class="devsite-footer-utility-link gc-analytics-event" href="https://developer-android-com.translate.goog/updates?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=auto" data-category="Site-Wide Custom Events" data-label="Footer Subscribe link"> Subscribe </a></li> </ul><devsite-language-selector> <ul role="presentation"> <li role="presentation"><a role="menuitem" lang="en">English</a></li> <li role="presentation"><a role="menuitem" lang="de">Deutsch</a></li> <li role="presentation"><a role="menuitem" lang="es_419">Español – América Latina</a></li> <li role="presentation"><a role="menuitem" lang="fr">Français</a></li> <li role="presentation"><a role="menuitem" lang="id">Indonesia</a></li> <li role="presentation"><a role="menuitem" lang="it">Italiano</a></li> <li role="presentation"><a role="menuitem" lang="pl">Polski</a></li> <li role="presentation"><a role="menuitem" lang="pt_br">Português – Brasil</a></li> <li role="presentation"><a role="menuitem" lang="vi">Tiếng Việt</a></li> <li role="presentation"><a role="menuitem" lang="tr">Türkçe</a></li> <li role="presentation"><a role="menuitem" lang="ru">Русский</a></li> <li role="presentation"><a role="menuitem" lang="he">עברית</a></li> <li role="presentation"><a role="menuitem" lang="ar">العربيّة</a></li> <li role="presentation"><a role="menuitem" lang="fa">فارسی</a></li> <li role="presentation"><a role="menuitem" lang="hi">हिंदी</a></li> <li role="presentation"><a role="menuitem" lang="bn">বাংলা</a></li> <li role="presentation"><a role="menuitem" lang="th">ภาษาไทย</a></li> <li role="presentation"><a role="menuitem" lang="zh_cn">中文 – 简体</a></li> <li role="presentation"><a role="menuitem" lang="zh_tw">中文 – 繁體</a></li> <li role="presentation"><a role="menuitem" lang="ja">日本語</a></li> <li role="presentation"><a role="menuitem" lang="ko">한국어</a></li> </ul> </devsite-language-selector> </nav> </div> </devsite-footer-utility> <devsite-panel></devsite-panel> </section> </section><devsite-sitemask></devsite-sitemask> <devsite-snackbar></devsite-snackbar> <devsite-tooltip></devsite-tooltip> <devsite-heading-link></devsite-heading-link> <devsite-analytics> <script type="application/json" analytics>[]</script> <script type="application/json" tag-management>{"at": "True", "ga4": [{"id": "G-QFRN08RN6E", "purpose": 0}], "ga4p": [{"id": "G-QFRN08RN6E", "purpose": 0}], "gtm": [{"id": "GTM-KMSWPCJ", "purpose": 0}], "parameters": {"internalUser": "False", "language": {"machineTranslated": "False", "requested": "en", "served": "en"}, "pageType": "article", "projectName": "Background work", "signedIn": "False", "tenant": "android", "recommendations": {"sourcePage": "", "sourceType": 0, "sourceRank": 0, "sourceIdenticalDescriptions": 0, "sourceTitleWords": 0, "sourceDescriptionWords": 0, "experiment": ""}, "experiment": {"ids": ""}}}</script> </devsite-analytics> <devsite-badger></devsite-badger> <android-fully-clickable target=" .android-case-study .devsite-landing-row-item, .android-grouped-resources .devsite-landing-row-item, .android-grouped-resources-primary .devsite-landing-row-item, .android-grouped-resources-secondary .devsite-landing-row-item, .android-guide-cards .devsite-landing-row-item, .android-illustrated-resources-index .devsite-landing-row-item, .android-illustrated-resources-primary .devsite-landing-row-item, .android-illustrated-resources-secondary .devsite-landing-row-item, .android-illustrated-resources-secondary-small .devsite-landing-row-item, .android-illustrated-resources-tertiary .devsite-landing-row-item, .android-illustrated-resources-tertiary-small .devsite-landing-row-item, .android-promo .devsite-landing-row-item, .android-quick-link, .android-samples .devsite-card-wrapper, .fully-clickable" watch=".android-samples, devsite-content"></android-fully-clickable> <script nonce="zbLXFSJVlJ5lP07cSAk3oE+ZybPuhP"> (function(d,e,v,s,i,t,E){d['GoogleDevelopersObject']=i; t=e.createElement(v);t.async=1;t.src=s;E=e.getElementsByTagName(v)[0]; E.parentNode.insertBefore(t,E);})(window, document, 'script', 'https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/js/app_loader.js', '[3,"en",null,"/js/devsite_app_module.js","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android","https://android-dot-devsite-v2-prod.appspot.com",1,null,["/_pwa/android/manifest.json","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/images/video-placeholder.svg","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/favicon.svg","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup.svg","https://fonts.googleapis.com/css?family=Google+Sans:400,500,600,700|Google+Sans+Text:400,400italic,500,500italic,600,600italic,700,700italic|Roboto+Mono:400,500,700&display=swap"],1,null,[1,6,8,12,14,17,21,25,50,52,63,70,75,76,80,87,91,92,93,97,98,100,101,102,103,104,105,107,108,109,110,112,113,116,117,118,120,122,124,125,126,127,129,130,131,132,133,134,135,136,138,140,141,147,148,149,151,152,156,157,158,159,161,163,164,168,169,170,179,180,182,183,186,191,193,196],"AIzaSyAP-jjEJBzmIyKR4F-3XITp8yM9T1gEEI8","AIzaSyB6xiKGDR5O3Ak2okS4rLkauxGUG7XP0hg","developer.android.com","AIzaSyAQk0fBONSGUqCNznf6Krs82Ap1-NV6J4o","AIzaSyCCxcqdrZ_7QMeLCRY20bh_SXdAYqy70KY",null,null,null,["DevPro__enable_developer_subscriptions","Search__enable_ai_eligibility_checks","MiscFeatureFlags__enable_firebase_utm","Profiles__enable_profile_collections","Cloud__enable_cloud_shell_fte_user_flow","Cloud__enable_cloudx_experiment_ids","Cloud__enable_cloud_shell","Profiles__enable_dashboard_curated_recommendations","Profiles__enable_recognition_badges","MiscFeatureFlags__enable_dark_theme","Search__enable_page_map","TpcFeatures__enable_required_headers","Search__enable_suggestions_from_borg","Profiles__enable_completecodelab_endpoint","Profiles__enable_complete_playlist_endpoint","Profiles__enable_awarding_url","CloudShell__cloud_shell_button","MiscFeatureFlags__developers_footer_dark_image","DevPro__enable_cloud_innovators_plus","Profiles__enable_developer_profiles_callout","MiscFeatureFlags__enable_project_variables","Search__enable_dynamic_content_confidential_banner","TpcFeatures__enable_mirror_tenant_redirects","Profiles__require_profile_eligibility_for_signin","Experiments__reqs_query_experiments","Cloud__enable_cloud_facet_chat","MiscFeatureFlags__enable_variable_operator","Profiles__enable_release_notes_notifications","MiscFeatureFlags__emergency_css","Analytics__enable_clearcut_logging","Cloud__enable_llm_concierge_chat","BookNav__enable_tenant_cache_key","CloudShell__cloud_code_overflow_menu","Cloud__enable_cloudx_ping","Concierge__enable_pushui","Profiles__enable_public_developer_profiles","Significatio__enable_by_tenant","Cloud__enable_free_trial_server_call","Cloud__enable_cloud_dlp_service","Cloud__enable_legacy_calculator_redirect","MiscFeatureFlags__developers_footer_image","Profiles__enable_page_saving","MiscFeatureFlags__enable_view_transitions","EngEduTelemetry__enable_engedu_telemetry"],null,null,"AIzaSyBLEMok-5suZ67qRPzx0qUtbnLmyT_kCVE","https://developerscontentserving-pa.googleapis.com","AIzaSyCM4QpTRSqP5qI4Dvjt4OAScIN8sOUlO-k","https://developerscontentsearch-pa.googleapis.com",2,4,null,"https://developerprofiles-pa.googleapis.com",[3,"android","Android Developers","developer.android.com",null,"android-dot-devsite-v2-prod.appspot.com",null,null,[null,1,null,null,null,null,null,null,null,null,null,[1],null,null,null,null,null,null,[1],[1,null,null,[1,20],"/recommendations"],null,null,null,[1,null,1],[1,1,null,1,1]],null,[18,null,null,null,null,null,"/images/lockup.svg","/images/touchicon-180.png",null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,"/images/lockup-dark-theme.svg",[]],[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[6,1,14,15,20,22,23,28,29,37,43],null,[[null,null,1],[1,1]],[[null,null,null,null,null,null,null,[["G-QFRN08RN6E"],null,null,[["G-QFRN08RN6E",1]]],null,null,null,null,1],null,[[1,1],[2,2]]],null,4,null,null,null,null,null,null,null,null,null,null,null,null,null,"android.devsite.google"],1,"pk_live_5170syrHvgGVmSx9sBrnWtA5luvk9BwnVcvIi7HizpwauFG96WedXsuXh790rtij9AmGllqPtMLfhe2RSwD6Pn38V00uBCydV4m"]') </script><devsite-a11y-announce></devsite-a11y-announce> <script>function gtElInit() {var lib = new google.translate.TranslateService();lib.translatePage('en', 'en', function () {});}</script> <script src="https://translate.google.com/translate_a/element.js?cb=gtElInit&hl=auto&client=wt" type="text/javascript"></script> </body> </html>