You are on page 1of 103
anv2i24, 1:90 PM Servigo [DesenvoWedores Android ‘Adicionado na API nivel1 (/guide/topics/manifestluses-sdk-element#ApiLevels) Servi¢co Kotlin (/reference/kotlin/android/app/Service) - Brasil | Java public abstract class Service extends ContextWrapper (/reference/androidicontent/ContextWrapper) implements ComponentCal1backs2 (/reference/androidicontent/ComponentCallbacks2) java lang.Objeto (/reference/javalang/Object) indroid. content. Contexto (/reference/androidicontent/Context) |, android. content. ContextWrapper (/reference/android/content/ContextWrapper) android.app.Servico Subclasses diretas conhecidas AbstractinputMethodService (/reference/android/nputmethodservice/AbstractinputMethodService), A (ireference/androidservice/autofillAutofillService), CallRedirectionService (/reference/android/telecon CameraPrewarmService (/reference/androidservice/media/CameraPrewarmService), CarrierMessagin CarrierMessagingService (/reference/androidsservicelearrier/CarrierMessagingService), CarrierService (ireferencefandroidiservice/chooser/ChooserTargetService), CompanionDeviceService (/reference/an (ireferencesandroid/servicemnotification/ConditionProviderService), ConnectionService (/reference/anc (Ireferencefandroid/service/controls/ControlsProviderService), CredentialProviderService (/referenceh AbstractinputMethodService AbstractinputMethodServic (ireference/androidinputmethodservice/AbstractInputMethodService) AccessibilityService Accessibility services shou (ireference/android/accessibilityservice/AccessibilityService) AutofilService (/referencefandroidiservice/autofillAutofillService) Anis a service used to aut: read Autofill Framework (/p CallRedirectionService This service can be implem (ireference/android/telecom/CallRedirectionService) redirection/cancellation pul CallScreeningService (/reference/android/telecom/CallScreeningService) This service can be implem shown to a user. Telecom! (ireferencefandroiditeleco CameraPrewarmService Extend this class to implerr (ieference/androidsservice/media/CameraPrewarmService) CarrierMessagingClientService If the default SMS app has (ireferencefandroidservice/carrier/CarrierMessagingClientService) which allows the app to ha hitosvldeveloperandroll.comireferencelandoldlappiService smi03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android CarrierMessagingService A service that receives call (ireference/androidservice/carrier/CarrierMessagingService) CarrierService (reference/androidiservicelearrier/CarrierService) A service that exposes car ChooserTargetService This class was deprecated (ireferencefandroidservice/chooseriChooserTargetService) https:/ideveloper. android.cc ‘CompanionDeviceService A service that receives call (ireference/android/companion/CompanionDeviceService) nditionProviderServi This class was deprecated (ireference/androidiservice/notification/ConditionProviderService) NotificationManager.s¢ (ireferencefandroid/app/Nc to tell the system about the configuration activity that / (ireferencefandroid/app/Nc (ireferencefandroidfapp/Au (/referencefandroid/app/Au ConnectionService (/reference/androiditelecom/ConnectionService) An abstract service that sh 1. Can make phone calls ( ControlsProviderService Service implementation alc (reference/androidiservice/controls/ControlsProviderService) CredentialProviderService Service to be extended by (referencefandroidfservice/credentials/CredentialProviderService) DeviceAdminService (/reference/android/app/admin/DeviceAdminService) Base class for a service thi DreamService (/reference/android’service/dreams/DreamService) Extend this class to implerr HostApduService (/reference/androidinfc/cardemulation/HostApduService) HostApduService is a conv: Service (/reference/andro HostNfcFService (/referencefandroidinfc/cardemulation/HostNfcFService) HostNfcFService is a convi Service (/reference/andro InGallservice (/reference/android/telecom/nCallservice) This service is implementec IntentService (/reference/android/app/intentService) This class was deprecated (fabout/versions/oreo/back (https:/ideveloper.android.. IsolatedService Base class for services tha (ireferenceandroid/adservicesiondevicepersonalization/IsolatedService) _(https:/ideveloper.android. OnDevicePersonalizatic OutcomeReceiver) JobService (/reference/androidappijobUobService) Entry point for the callback hitosvldeveloperandroll.comireferencelandoldlappiService anos anv2i24, 1:90 PM Servigo [DesenvoWedores Android MediaBrowserService Base class for media brows (Wreference/android/service’media/MediaBrowserService) MediaRoute2ProviderService Base class for media route (ireferencefandroidimedia/MediaRoute2ProviderService) MediaSession2Service (/reference/androidimedia/MediaSession2Service) This API is not generally int MidiDeviceService (/teference/androidimediaimidi/MidiDeviceService) A service that implements MidimpDeviceService A service that implements (ireference/androidimediamidi/MidiUmpDeviceService) NotificationListenerService A service that receives call (ireference/androidservicemotification/NotificationListenerService) OfftiostApduService OffHostApduService is a cc (ireference/androidinfc/cardemulation/OffHostApduService) host, for example on an err PrintService (ireference/android/printservice/PrintService) This is the base class for in QuickAccessWalletService A provides a list of s showr (ireference/androidiservice/quickaccesswallet/QuickAccessWalletService) RecognitionService (/reference/androidspeech/RecognitionService) This class provides a base RemoteViewsService (/reference/android/widget/RemoteViewsService) The service to be connect« SettinglnjectorService (/reference/androidlocation/SettingInjectorService) Dynamically specifies the s the system settings app For use only by apps that ¢ ‘SpellCheckerService SpellCheckerService provic (ireference/androidiservice/textservice/SpellCheckerService) TextToSpeechService Abstract base class for TTS (ireferencefandroidspeech/tts/TextToSpeechService) TileService (/reference/androidiservice/quicksettings/TileService) ATileService provides the « ‘TunputService (/reference/androidimedia/twTvinputService) The TuinputService class re broadcast TV programs. ‘TunteractiveAppService ATV interactive applicatior (ireference/androidimedia/twinteractive/TvinteractiveAppService) VisualVoicemailService This service is implementec (ireference/android/telephony/VisualVoicemailService) VoicelnteractionService Top-level service of the cul (ireference/androidservice/voice/VoiceinteractionService) VoiceInteractor (/refere WoiceinteractionSessionService ‘An active voice interaction (ireference/androidiservice/voice/VoiceinteractionSessionService) (referencesandroidiservice hitosvldeveloperandroll.comireferencelandoldlappiService st03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android VpnService (/reference/androidmetVpnService) VpnService is a base class VilistenerService (/reference/androidiservice//VrListenerService) A service that is bound fro WallpaperService (/reference/android/service/walipaper/WallpaperService) A wallpaper service is resp: Subclasses indiretas conhecidas InputMethodService (/reference/androidinputmethodservice/InputMethodService) InputMethodService InputMethodService provides a (ireference/androidinputmethodservice/InputMethodService) standard implementation of an InputMethod, which final implementations can derive from and customize. Um Servigo & um componente de aplicativo que representa o desejo de um aplicativo para executar uma operagiio de execugao mais longa enquanto nao interage com o usuario ou para fornecer funcionalidade para outros aplicativos usarem. Cada servico classe deve ter uma declaragio correspondente em seu pacote . Servigos pode ser iniciado come. (/reference/android/R.styleable#AndroidManifestService) AndroidManifest . xml Context .startService() (/reference/androidicontent/Context#startService(android.content. Intent)) Context. bindService() (/reference/androidicontent/Context#bindService(android.content.|ntent,%20android.content.Context. Bi ndServiceFlags, %20java.util.concurrent.Executor, %20android.content.ServiceConnection)) Observe que os servigos, como outros objetos de aplicativo, s4o executados na principal thread de seu processo de hospedagem. Isso significa que, se 0 seu servigo esta indo para fazer qualquer CPU intensiva (como reprodugao de MP3) ou bloqueio (como networking), ele deve gerar seu préprio fio condutor para fazer isso trabalho. Mais informagées sobre isso podem ser encontradas em Processos e Topicos: (fguide/topics/fundamentals/processes-and-threads). A aula esta disponivel como uma implementagao padrao do Servico que tem seu préprio thread onde agenda seu trabalho para ser feito. JobIntentService (https:/ideveloper. android. com/reference/androidx/core/appUobintentService.html) Tépicos abordados aqui hitosvldeveloperandroll.comireferencelandoldlappiService 4n03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android 1, O.que é um Servigo? (#WhatisAService) 2. Ciclo de vida do servico (#ServiceLifecycle) 3. Permissées (#Permissions) clo de vida do processo (#ProcessLifecycle) 5. Exemplo de servi¢o local (#LocalServiceSample) 6. Exemplo de servico de mensageiro remoto (#RemoteMessengerServiceSample) Guias do desenvolvedor Para obter uma discussao detalhada sobre como criar servigos, leia 0 Guia do desenvolvedor de servigos (/guide/topics/fundamentalsservices) O que é um Servico? A maior parte da confusao sobre a classe Service realmente gira em torno do que no é: + Um Servico nao é um processo separado. O préprio objeto Service nao implica que esteja a correr no seu proprio processo; salvo disposigao em contrario, ele é executado no mesmo processo que o aplicativo do qual faz parte. + Um Servico no é um thread. Nao é um meio em si para fazer trabalho fora do thread principal (para evitar erros de aplicativo nao respondendo). Assim, um Servigo emi é realmente muito simples, fornecendo duas caracteristicas principais: + Uma facilidade para 0 aplicativo informar ao sistema sobre algo que ele quer estar fazendo em segundo plano (mesmo quando o usuario nao esta interagindo diretamente com 0 aplicativo). Isso corresponde a chamadas para , que solicitar a0 sistema que agende o trabalho para o servico, a ser executado até o servico ou alguém o pare explicitamente. Context. startService() (/reference/android/content/Context#startService(android.content.Intent)) + Um recurso para um aplicativo expor algumas de suas funcionalidades a outras aplicagées. Isso corresponde a chamadas para , que permite que uma conexao de hitosvldeveloperandroll.comireferencelandoldlappiService 51103 anv2i24, 1:90 PM Servigo [DesenvoWedores Android longa data seja feita com o servigo, a fim de interagir com ele. Context. bindService() (ireference/android/content/Context#tbindService(android.content intent, %20android.content.Con text.BindServiceFlags, %20java.util. concurrent. Executor, %20android.content.ServiceConnection)) Quando um componente de servigo é realmente criado, por um desses motivos, tudo o que o sistema realmente faz é instanciar o componente e chame seu e quaisquer outros retornos de chamada apropriados no fio condutor. Cabe ao Servigo implementa-los com as devidas providéncias comportamento, como criar um thread secundario no qual ele faz seu trabalho oncreate() (/reference/androidiapp/ServicestonCreate()) Observe que, como 0 Servico em si é to simples, vocé pode fazer o seu interacao com ele to simples ou complicado quanto vocé quer: de tratd-lo como um objeto Java local no qual vocé faz chamadas diretas de método (conforme ilustrado por Amostra de Servico Local (#LocalServiceSample)), para fornecer uma interface totalmente remota usando AIDL. Ciclo de vida do servico Ha duas razées pelas quais um servigo pode ser executado pelo sistema. Se alguém chama entao o sistema iré recuperar o servigo (criando-o e chamando seu método se necessario) e, em seguida, chame seu método com o argumentos fornecidos pelo cliente. O servigo continuara neste momento executando até ou é chamado. Observe que varias chamadas para Context.startService() nao aninham (embora resultem em varios correspondentes chama para onStartCommand()), portanto, nao importa quantas vezes seja iniciado um servigo sera interrompido quando Context.stopService() ou stopSelf() for chamado; contudo Os servigos podem usar seu método para garantir que 0 servigo seja nao interrompido até que as intengdes iniciadas tenham sido processadas. Context. startService() (/reference/androidicontent/Context#startService(android.content.intent)) onCreate( ) (/reference/android/app/Service#onCreate()) onStartCommand(Intent,_int,_int) (Wreferencefandroid/app/Service#onStartCommand(android.content.Intent,%20int,%20int)) Context. stopService() (ireference/android/content/ContextitstopService(android.content.intent)) stopSelf() (/reference/android/app/Service#stopSelf()) stopSelf (int) (Wreference/android/app/Service##stopSelf(int)) Para servigos iniciados, ha dois modos principais adicionais de operagao eles podem decidir correr, dependendo do valor que retornam onStartCommand(): é usado para servigos que s&o explicitamente iniciado e interrompido conforme necessério, enquanto ou so usados para servigos que devem apenas permanecem em execucao enquanto processam quaisquer comandos enviados a eles. Veja o link documentagao para mais detalhes sobre a semantica. START_STICKY (/reference/android/app/Service##START_STICKY) hitosvldeveloperandroll.comireferencelandoldlappiService anos anv2i24, 1:90 PM Servigo [DesenvoWedores Android ‘START_NOT_STICKY (/reference/android/app/Service#START_NOT_STICKY) START_REDELIVER_INTENT (Wreferencefandroid/app/ServicettSTART_REDELIVER_INTENT) Os clientes também podem usar para Obter uma conexdo persistente com um servico. Isso também cria 0 se ainda nao estiver em execugao (chamando enquanto fazendo isso), mas no chama onStartCommand(). O cliente receberd 0 objeto que o servico retorna de seu método, permitindo que o cliente faga chamadas de volta ao servico. O servico permanecera em execugdo enquanto durar a conexao é estabelecido (quer o cliente mantenha ou nao uma referéncia sobre o IBinder do servigo). Normalmente o IBinder devolvido é para um complexo interface que foi escrita em aidl ({quide/components/aid)). Context. bindService() (referencefandroidicontent/Context#bindService(android.content. Intent, %20android.content.Context.Bi ndServiceFlags, %20java.util.concurrent.Executor, %20android, content ServiceConnection)) onCreate() (reference/android/app/ServicetonCreate()) IBinder (/reference/android/os/IBinder) ‘onBind (Intent) (/reference/android/app/Service#onBind(android.content. Intent)) Um servigo pode ser iniciado e ter conexGes vinculadas a ele. Em tal um caso, o sistema mantera 0 servigo em execugo enquanto ele for iniciado ou hd uma ou mais conexées com ele com o sinalizador. Uma vez que nenhum dos dois dessas situagdes se mantém, 0 método do servigo é chamado de e o servigo é efetivamente encerrado. Toda a limpeza (parando threads, descadastrar receptores) deve ser concluido ao retornar de onDestroy(). Context .BIND_AUTO_CREATE (/reference/android/content/Context#BIND_AUTO_CREATE) onDestroy() (/reference/android/app/ServicettonDestroy()) Permissées Oacesso global a um servigo pode ser imposto quando ele é declarado em seu Tag do manifesto. Ao fazer isso, outros aplicativos precisarao declarar um elemento correspondente em seu préprio manifesto para poder iniciar, parar ou vincular a o servigo. (/reference/android/R.styleable# AndroidManifestService) (/reference/android/R.styleable# AndroidManifestUsesPermission) As of , when using,, you can also set and/or on the Intent. This will grant the Service temporary access to the specific URIs in the Intent. Access will remain until the Service has. called for that start command or a later one, or until the Service has been completely stopped. This works for granting access to the other apps that have not requested the permission protecting the Service, or even when the Service is not exported at all. Build. VERSION CODES. GINGERBREAD (/reference/android/os/Build.VERSION_CODES#GINGERBREAD) Context. startService(Intent) hitosvldeveloperandroll.comireferencelandoldlappiService mos anv2i24, 1:90 PM Servigo [DesenvoWedores Android (Wreferencefandroidicontent/Context#startService(android.content.ntent)) Intent.FLAG_GRANT_READ_URT_PERMISSION (referencefandroidicontent/intent#FLAG_GRANT_READ_URI_PERMISSION) Intent .FLAG_GRANT_WRITE_URT_PERNISSION Ureference/androidicontentiintent#FLAG_GRANT_WRITE_URI_PERMISSION) stopSelf (int) (Wreferencefandroid/app/ServicettstopSelt{int)) In addition, a service can protect individual IPC calls into it with permissions, by calling the method before executing the implementation of that call. ContextWrapper_.checkCallingPermission(String) (/referencefandroidicontent/ContextWrapperttcheckCallingPermission (java.lang.String)) See the Security and Permissions (/guide/topicssecuritysecurity) document for more information on permissions and security in general Process Lifecycle The Android system will attempt to keep the process hosting a service around as long as. the service has been started or has clients bound to it. When running low on memory and needing to kill existing processes, the priority of a process hosting the service will be the higher of the following possibilities: + If the service is currently executing code in its , , or methods, then the hosting process will be a foreground process to ensure this code can execute without being killed. onCreate() (/reference/android/app/Service#onCreate()) onStartCommand( ) (ireference/android/app/Service# onStartCommand(android.content.Intent, %2¢ %20int)) onDestroy() (/reference/android/app/Service#onDestroy()) * If the service has been started, then its hosting process is considered to be less important than any processes that are currently visible to the user on-screen, but more important than any process not visible. Because only a few processes are generally visible to the user, this means that the service should not be killed except in low memory conditions. However, since the user is not directly aware of a background service, in that state it is considered a valid candidate to kill, and you should be prepared for this to happen. In particular, long-running services will be increasingly likely to kill and are guaranteed to be killed (and restarted if appropriate) if they remain started long enough. hitosvldeveloperandroll.comireferencelandoldlappiService anos Servigo [DesenvoWedores Android * If there are clients bound to the service, then the service's hosting process is never less important than the most important client. That is, if one of its clients is visible to the user, then the service itself is considered to be visible. The way a client's importance impacts the service's importance can be adjusted through, ,,, and. Context#BIND_ABOVE CLIENT (/reference/android/content/Context#BIND_ABOVE CLIENT) Context#BIND_ALLOW_OOM MANAGEMENT (/reference/android/content/Context#BIND_ALLOW_OOM_MANAGEMENT) Context#BIND_WAIVE PRIORITY (/reference/android/content/Context#BIND_WAIVE_PRIORITY) Context#BIND_IMPORTANT (/reference/androidicontent/Context#BIND_IMPORTANT) Context#BIND_ADJUST_WITH_ ACTIVITY (ireferencefandroid/content/Context#BIND_ADJUST.WITH_ACTIVITY) + Astarted service can use the AP! to put the service in a foreground state, where the system considers it to be something the user is actively aware of and thus not a candidate for killing when low on memory. (It is still theoretically possible for the service to be killed under extreme memory pressure from the current foreground application, but in practice this should not be a concern.) startForeground(int,, android. app.Notification) (ireferencefandroid/app/Service#tstartForeground(int, %20android.app.Notification)) Note this means that most of the time your service is running, it may be killed by the system if it is under heavy memory pressure. If this happens, the system will later try to restart the service. An important consequence of this is that if you implement to schedule work to be done asynchronously or in another thread, then you may want to use to have the system re- if your service is killed while processing deliver an Intent for you so that it does not get lost it. onStartCommand() (ireferencefandroid/app/Service#onStartCommand(android.content.Intent,%20int,%20int)) ‘START_FLAG_REDELIVERY (/reference/androidiapp/Service##START_FLAG_REDELIVERY) Other application components running in the same process as the service (such as an) can, of course, increase the importance of the overall process beyond just the importance of the service itself. Activity (/reference/android/app/Activity) Local Service Sample One of the most common uses of a Service is as a secondary component running alongside other parts of an application, in the same process as the rest of the components. All components of an .apk run in the same process unless explicitly stated otherwise, so this is a typical situation. hitosvldeveloperandroll.comireferencelandoldlappiService anos anv2i24, 1:90 PM Servigo [DesenvoWedores Android When used in this way, by assuming the components are in the same process, you can greatly simplify the interaction between them: clients of the service can simply cast the [Binder they receive from it to a concrete class published by the service. An example of this use of a Service is shown here. First is the Service itself, publishing a custom class when bound: public class LocalService extends Service { private NotificationManager mNM; // Unique Identification Number for the Notification. // We use it on Notification start, and to cancel it. private int NOTIFICATION = R.string.local_service_started; ye * Class for clients to access. Because we know this service always * runs in the same process as its clients, we don't need to deal with * Ipc. *” public class LocalBinder extends Binder { LocalService getService() { return LocalService. this; @0verride public void onCreate() { mNM = (NotificationManager )getSystemService(NOTIFICATION_SERVICE) ; // Display a notification about us starting. We put an icon in the status b showNotification() ; @0verride public int onStartCommand(Intent intent, int flags, int startId) { Log.i(*LocalService”, "Received start id" + startId + + intent); return START_NOT_STICKY; @0verride public void onDestroy() { // Cancel the persistent notification. mNM.cancel (NOTIFICATION) ; hitosvldeveloperandroll.comireferencelandoldlappiService son03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android // Tell the user we stopped Toast.makeText(this, R.string.local_service_stopped, Toast.LENGTH_SHORT) .sho @0verride public IBinder onBind(Intent intent) { return mBinder ; } // This is the object that receives interactions from clients. See // RemoteService for a more complete example. private final IBinder mBinder = new LocalBinder(); i * Show a notification while this service is running. *” private void showNotification() { // In this sample, we'll use the same text for the ticker and the expanded n CharSequence text = getText(R.string.local_service_started) ; JJ The PendingIntent to launch our activity if the user selects this notific PendingIntent contentIntent = PendingIntent.getActivity(this, 2, new Intent(this, LocalServiceActivities.Controller.class), @); // Set the info for the views that show in the notification panel Notification notification = new Notification Builder(this) -setSmallIcon(R.drawable.stat_sample) // the status icon -setTicker(text) // the status text setWhen(System.currentTimeMillis()) // the time stamp -setContentTitle(getText(R.string.local_service_label)) // the labe -setContentText(text) // the contents of the entry -setContentIntent(contentIntent) // The intent to send when the ent build(); // Send the notification. NM. notify(NOTIFICATION, notification) ; With that done, one can now write client code that directly accesses the running service, such as: hitosvldeveloperandroll.comireferencelandoldlappiService sito. anv2i24, 1:90 PM Servigo [DesenvoWedores Android ys Example of binding and unbinding to the local service. bind to, receiving an object through which it can communicate with the service. Note that this is implemented as an inner class only keep the sample all together; typically this code would appear in some separate class. * public static class Binding extends Activity { // Don't attempt to unbind from the service unless the client has received some // information about the service's state. private boolean mShouldUnbind; // To invoke the bound service, first make sure that this value // is not null. private LocalService mBoundService; private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { // This is called when the connection with the service has been // established, giving us the service object we can use to // interact with the service. Because we have bound to a explicit // service that we know is running in our own process, we can // cast its IBinder to a concrete class and directly access it. mBoundService = ((LocalService.LocalBinder)service) .getService(); // Tell the user about this for our demo. Toast makeText (Binding. this, R.string.local_service_connected, Toast .LENGTH_SHORT) .show() ; public void onServiceDisconnected(ComponentName className) { // This is called when the connection with the service has been // unexpectedly disconnected -- that is, its process crashed. // Because it is running in our same process, we should never 11 see this happen. mBoundService = null; Toast .makeText (Binding. this, R.string.local_service_disconnected, Toast..LENGTH_SHORT) .show() ; hi void doBindService() { // Attempts to establish a connection with the service. We use an // explicit class name because we want a specific service hitosvldeveloperandroll.comireferencelandoldlappiService sanos anv2i24, 1:90 PM Servigo [DesenvoWedores Android // implementation that we know will be running in our own process // (and thus won't be supporting component replacement by other 11 applications) . if (bindService(new Intent(Binding.this, LocalService.class), mConnection, Context .BIND_AUTO_CREATE)) { mShouldUnbind = true; } else { Log.e("MY_APP_TAG", "Error: The requested service doesn't exist, or this client isn't allowed access to it void doUnbindService() { if (mShouldUnbind) { // Release information about the service's state. unbindService(mConnection) ; mShouldUnbind = false; @0verride protected void onDestroy() { super .onDestroy(); doUnbindservice() ; Remote Messenger Service Sample If you need to be able to write a Service that can perform complicated communication with clients in remote processes (beyond simply the use of to send commands tot), then you can use the class instead of writing full AIDL files. Context startService (/reference/androidicontent/Context#startService(android.content.intent)) Messenger (/reference/android/os/Messenger) An example of a Service that uses Messenger as its client interface is shown here. First is the Service itself, publishing a Messenger to an internal Handler when bound: public class MessengerService extends Service { 7** For showing and hiding our notification. */ NotificationManager mNM; hitosvldeveloperandroll.comireferencelandoldlappiService ssn03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android /** Keeps track of all current registered clients. */ ArrayList mClients = new ArrayList(); /** Holds last value set by a client. */ int mValue = @; i * Command to the service to register a client, receiving callbacks * from the service. The Message's replyTo field must be a Messenger of * the client where callbacks should be sent. *” static final int MSG_REGISTER_CLIENT = 1 ee * Command to the service to unregister a client, ot stop receiving callbacks * from the service. The Message's replyTo field must be a Messenger of * the client as previously given with MSG_REGISTER_CLIENT. *” static final int MSG_UNREGISTER_CLIENT ys * Command to service to set anew value. This can be sent to the * service to supply a new value, and will be sent by the service to * any registered clients with the new value. *” static final int MSG_SET_VALUE re * Handler of incoming messages from clients. *” class IncomingHandler extends Handler { @0verride public void handleMessage(Message msg) { switch (msg.what) { case MSG_REGISTER_CLIENT: mCLients.add(msg.replyTo) ; break; case MSG_UNREGISTER_CLIENT: Clients. remove(msg.replyTo) ; break; case MSG_SET_VALUE: mValue = msg.argl; for (int ismClients.size()-1; i>=0; try ¢ mCLients..get (i) .send(Message.obtain(nul1, MSG_SET_VALUE, nValue, @)); 4 hitosvldeveloperandroll.comireferencelandoldlappiService anos anv2i24, 1:90 PM Servigo [DesenvoWedores Android } catch (RemoteException e) { // The client is dead. Remove it from the list; // we are going through the list from back to front // 0 this is safe to do inside the loop. mClients.remove(i) ; } } break; default super .handleMessage(msg) ; } } } pee * Target we publish for clients to send messages to IncomingHandler. * final Messenger messenger = new Messenger(new IncomingHandler()) ; @0verride public void onCreate() { mNM = (NotificationManager ) getSystemService(NOTIFICATION_SERVICE) ; // Display a notification about us starting. showNotification(); @0verride public void onDestroy() { // Cancel the persistent notification mNM.cancel(R.string.remote_service_started) ; // Tell the user we stopped. Toast.makeText(this, R.string.remote_service_stopped, Toast.LENGTH_SHORT) sh ye * When binding to the service, we return an interface to our messenger * for sending messages to the service. * e0verride public IBinder onBind(Intent intent) { return messenger .getBinder() ; hitosvldeveloperandroll.comireferencelandoldlappiService 5103 anv2i24, 1:90 PM Servigo [DesenvoWedores Android i * Show a notification while this service is running *7 private void showNotification() { // In this sample, we'll use the same text for the ticker and the expanded n CharSequence text = getText(R.string.remote_service_started) ; // The PendingIntent to launch our activity if the user selects this notific PendingIntent contentIntent = PendingIntent.getActivity(this, @, new Intent(this, Controller.class), 8); // Set the info for the views that show in the notification panel. Notification notification = new Notification. Builder(this) setSmallIcon(R.drawable.stat_sample) // the status icon -setTicker(text) // the status text -setWhen(System.currentTimeMillis()) // the time stamp -setContentTitle(getText(R.string.local_service_label)) // the labe setContentText(text) // the contents of the entry -setContentIntent(contentIntent) // The intent to send when the ent -build(); IJ Send the notification. // We use a string id because it is a unique number. We use it later to can mNM notify(R.string.remote_service_started, notification) ; If we want to make this service run in a remote process (instead of the standard one for its -apk), we can use in its manifest tag to specify one: android:process Note that the name "remote" chosen here is arbitrary, and you can use other names if you want additional processes. The “’ prefix appends the name to your package's standard process name. hitosvldeveloperandroll.comireferencelandoldlappiService 6103 anv2i24, 1:90 PM Servigo [DesenvoWedores Android With that done, clients can now bind to the service and send messages to it. Note that this allows clients to register with it to receive messages back as well: rs Example of binding and unbinding to the remote service. This demonstrates the implementation of a service which the client will bind to, interacting with it through an aidl interface * Note that this is implemented as an inner class only keep the sample * all together; typically this code would appear in some separate class. *7 public static class Binding extends Activity { /** Messenger for communicating with service. */ Messenger mService = null; /** Flag indicating whether we have called bind on the service. */ boolean mIsBound; 1** Some text view we are using to show state information. */ TextView mCallbackText; ys * Handler of incoming messages from service. * class IncomingHandler extends Handler { @0verride public void handleMessage(Message msg) { switch (msg.what) { case MessengerService.MSG_SET_VALUE mCallbackText.setText ("Received from service: " + msg.argi); break; default super .handleMessage(msg) : } } } pe * Target we publish for clients to send messages to IncomingHandler. *” final Messenger messenger = new Messenger(new IncomingHandler()) ; pe * Class for interacting with the main interface of the service. 7 hitosvldeveloperandroll.comireferencelandoldlappiService amos anv2i24, 1:90 PM Servigo [DesenvoWedores Android private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, } IBinder service) { // This is called when the connection with the service has been // established, giving us the service object we can use to // interact with the service. We are communicating with our // service through an IDL interface, so get a client-side // representation of that from the raw service object. mService = new Messenger (service) ; mal lbackText .setText("Attached."); // We want to monitor the service for as long as we are // connected to it. try { Message msg = Message.obtain(null, MessengerService.MSG_REGISTER_CLIENT) ; msg.replyTo = mMessenger; mService.send(msg) ; // Give it some value as an example. msg = Message.obtain(null, MessengerService .MSG_SET_VALUE, this.hashCode(), 8) ; mService.send(msg) ; } catch (RemoteException e) { // In this case the service has crashed before we could even 7/ do anything with it; we can count on soon being // disconnected (and then reconnected if it can be restarted) // 80 there is no need to do anything here. // As part of the sample, tell the user what happened. Toast .makeText(Binding.this, R.string.remote_service_connected, Toast .LENGTH_SHORT) . show() ; public void onServiceDisconnected(ComponentName className) { // This is called when the connection with the service has been // unexpectedly disconnected -- that is, its process crashed mService = null; mal lbackText . setText("Disconnected." // As part of the sample, tell the user what happened Toast .makeText(Binding.this, R.string.remote_service_disconnected, Toast .LENGTH_SHORT) . show() ; hitosvldeveloperandroll.comireferencelandoldlappiService san03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android i void doBindService() { // Establish a connection with the service. We use an explicit // class name because there is no reason to be able to let other // applications replace our component bindService(new Intent (Binding. this, MessengerService.class), mConnection, Context .BIND_AUTO_CREATE) ; mIsBound = true; Cal lbackText .setText("Binding.") ; void doUnbindService() { if (mIsBound) { // Tf we have received the service, and hence registered with // it, then now is the time to unregister. if (mService != null) { try { Message msg = Message. obtain(null, MessengerService .MSG_UNREGISTER_CLIENT) ; msg.replyTo = mMessenger; mService.send(msg) ; } catch (RemoteException e) { // There is nothing special we need to do if the service // has crashed. // Detach our existing connection. unbindService(mConnection) ; mIsBound = false; mCallbackText. setText("Unbinding.”); Summary Constants hitosvldeveloperandroll.comireferencelandoldlappiService s9n03 anv2i24, 1:90 PM int int int int int Servigo [DesenvoWedores Android START_CONTINUATION_ MASK (Ireferencefandroid/app/Service#START_CONTINUATION_MASK) Bits returned by describing how to continue the service if it is killed. onStartCommand(Intent,_int,_int) (ireferencefandroid/app/Service#onStartCommand(android.content.nte ‘START_FLAG_REDELIVERY (/reference/androidapp/Service#START_FLAC This flag is set in if the intent is a re-delivery of a previously delivered in service had previously returned but had been killed before calling for the onStartCommand(Intent, int,_int) (Wreferencefandroid/app/Service#tonStartCommand(android.content.int« ‘START_REDELIVER_INTENT (/reference/android/app/Service##START_REC stopSelf (int) (/reference/android/app/Service##stopSelf(int)) START_FLAG_RETRY (/reference/android/app/Service#START_FLAG_RETF This flag is set in if the Intent is a retry because the original attempt nev returned from . onStartCommand(Intent,_int,_ int), (ireferencefandroid/app/Service#onStartCommand(android.content.Int« ‘onStartConmand(android.content.Intent, int, int) (Wreferencefandroid/app/Service#tonStartCommand(android.content.int« START_NOT_STICKY (/reference/android/app/Service##START_NOT_STICK Constant to return from : if this service's process is killed while itis start from ), and there are no new start intents to deliver to it, then take the « started state and don't recreate until a future explicit call to. nStartc int,_int) (ireferencefandroid/app/Service#onStartCommand(android.content.Int« ‘onStartCommand (Intent, _int,_int) (Wreferencefandroid/app/ServicettonStartCommand(android.content.int« Context.startService(Intent) (/referencefandroidicontent/Context#startService(android.content.Inte ‘START_REDELIVER_INTENT (/reference/android/epp/Service#START_REC Constant to return from : if this service's process is killed while itis start from ), then it will be scheduled for a restart and the last delivered Inter again via . onStartCommand(Intent,_int,_int) (ireferencefandroid/app/Service#onStartCommand(android.content Inte onStartCommand(Intent, int, int) hitosvldeveloperandroll.comireferencelandoldlappiService 2oni0s anv2i24, 1:90 PM int int int int int Servigo [DesenvoWedores Android (ireferencefandroidiapp/Service #onStartCommand(android.content.intc onStartCommand Inten int) (ireferencefandroid/app/Service##onStartCommand(android.content.Int« START_STICKY (/reference/android/app/Service#START_STICKY) Constant to return from : if this service's process is killed while it is start from ), then leave it in the started state but don't retain this delivered in onStartCommand(Intent, int, int) (ireferencefandroid/app/Service#onStartCommand(android.content.Int« onStartCommand(Intent,_int,_int) (ireferencefandroid/app/Service#tonStartCommand(android.content.int« START. STICKY_ COMPATIBILITY (Ireterencefandroid/app/Service#START_STICKY_COMPATIBILITY) Constant to return from : compatibility version of that does not guaranti called again after being killed. onStartCommand(Intent,_int, int), (ireferencefandroid/app/Service##onStartCommand(android.content.Int« START_STICKY (/reference/android/app/Service#START_STICKY) onStartCommand(Intent,_int,_int) (Wreferencefandroid/app/ServicettonStartCommand(android.content.int« ‘STOP_FOREGROUND_DETACH (Ireferencefandroid/app/Service#STOP_FOREGROUND_DETACH) Selector for : if set, the notification previously supplied to will be detach service's lifecycle. stopForeground( int) (ireferencefandroid/app/Service#tstopForeground{int)) startForegroun Notification) (ireferencefandroid/app/Service#startForeground{int,%20android. app. ‘STOP_FOREGROUND_LEGACY (ireferencefandroid/app/ServicettSTOP_FOREGROUND_LEGACY) This constant was deprecated in API level 33. Use STOP_FOREGROUND_C (Ireferencefandroid/app/Service#STOP_FOREGROUND_DETACH) instea behavior was inconsistent, leading to bugs around unpredictable results ‘STOP_FOREGROUND_REMOVE (Ireferencefandroid/app/Service#STOP_FOREGROUND_REMOVE) hitosvldeveloperandroll.comireferencelandoldlappiService 2unos anv2i24, 1:90 PM Servigo [DesenvoWedores Android Selector for : if supplied, the notification previously supplied to will be ce removed from display. stopForeground (int) (ireferencefandroid/app/Service#tstopForeground(int))startForegroun Notification’ (ireferencefandroid/app/Service#startForeground(int,%20android.app.h Inherited constants From class android. content . Context (/reference/android/content/Context) ‘String (/reference/java/lang/String) ACCESSIBILITY. SERVICE (/reference/androidicontent/Context#AC Use with to retrieve a for giving the user feedback for UI events thr AccessibilityManager (/reference/androidiviewaccessibilityAcce String (rreference/javaltang/String) sccounr. SERVICE (/reference/android/content/Context#ACCOUNT Use with to retrieve a for receiving intents at a time of your choosir (/reference/android/accounts/AccountManager) String (/reference/javallang/StriNg) scr qyqTy SERVICE (/reference/android/content/Context#ACTIVITY Use with to retrieve a for interacting with the global system state. ¢ (Ireferencefandroid/app/ActivityManager) ‘String (/reference/java/lang/String) yi sew SERVICE (/reference/android:content/Context#ALARM. SER\ Use with to retrieve a for receiving intents at a time of your choosir (Wreferencefandroid/app/AlarmManager) String (/reference/javallang/StriNg) sppwrpGET_ SERVICE (/referencefandroid/content/Context#APPWIL Use with to retrieve a for accessing AppWidgets. getSystenServi (/reference/android/appwidget/AppWidgetManager) String (/reference/javalang/Strind) spp ops SERVICE (/reference/androidicontent/Context#APP_OPS_ Use with to retrieve a for tracking application operations on the der (/referencefandroid/app/AppOpsManager) hitosvldeveloperandroll.comireferencelandoldlappiService 2anos anv2i24, 1:90 PM Servigo [DesenvoWedores Android ‘String (/reference/javallang/String) app SEARCH SERVICE (/reference/android/content/Context#APP_S Use with to retrieve an for indexing and querying app data manage: (Wreference/android/app/appsearch/AppSearchManager) ‘String (reference/java/lang/String) yypt9 SERVICE (/reference/androidicontent/Contexti#AUDIO_SERV ‘String (/reference/java/lang/String), int int int int int int Use with to retrieve a for handling management of volume, ringer ir (referencefandroidimedia/AudioManager) BATTERY. SERVICE (/reference/android/content/Context# BATTERY | Use with to retrieve a for managing battery state. getSystemServi BIND ABOVE CLIENT (/reference/androidicontent/Context#BIND_A Flag for : indicates that the client application binding to this service (ireferencefandroid/content/Context#bindService(android.content. BIND_ADJUST_WITH_ ACTIVITY (/reference/androidicontent/Contex Flag for : If binding from an activity, allow the target service's proce process's overall importance is used to impact it. bindService(In (ireferencefandroid/content/Context#bindService(android.content. BIND_ALLOW_ACTIVITY_STARTS (/reference/android/content/Conte Flag for : If binding from an app that is visible, the bound service is, (Ireferencefandroid/content/Context#tbindService(android.content. BIND_ALLOW_OOM_MANAGEMENT (/reference/androidicontent/Contex Flag for : allow the process hosting the bound service to go throug! (ireferencefandroid/content/Context#bindService(android.content. BIND_AUTO_CREATE (/reference/androidicontent/Context#BIND_AU Flag for : automatically create the service as long as the binding ex (/referencefandroidicontent/Context#bindService(android.content. BIND_DEBUG_UNBIND (/reference/android/content/Context#BIND_D hitosvldeveloperandroll.comireferencelandoldlappiService 203 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Flag for : include debugging help for mismatched calls to unbind. b: (ireferencefandroid/content/Context#tbindService(android.content. ant BIND_EXTERNAL SERVICE (/reference/androidicontent/Context#BIt Flag for : The service being bound is an , service. (In (/referencefandroidicontent/Context#bindService(android.content. (WreferenceandroidiR attritisolatedProcess)external (/reference/e Jong BIND_EXTERNAL SERVICE LONG (/reference/androidicontent/Conte Works in the same way as, but i's defined as a value that is compe (ireferencefandroidicontent/Context BindServiceFlags) int BIND_IMPORTANT (/reference/androidicontent/Context#8IND_IMPC. Flag for : this service is very important to the client, so should be br (/referencefandroidicontent/Context#bindService(android.content. int BIND_INCLUDE_CAPABILITIES (/reference/androidicontent/Contex Flag for : If binding from an app that has specific capabilities due tc required permissions as well. bindService(Intent,_BindServic: (/reference/androidicontent/Context#bindService(android.content. int BIND_NOT_FOREGROUND (/reference/androidicontent/Context#BIND Flag for : don't allow this binding to raise the target service's proce: (Wreferencefandroidicontent/Context#bindService(android.content. ant BIND_NOT_PERCEPTIBLE (/reference/androidicontent/Context#BINI Flag for : If binding from an app that is visible or user-perceptible, Ic (Ireferencefandroidicontent/Context#tbindService(android.content. ant BIND_SHARED_ISOLATED_PROCESS (/reference/android/contenti/Cor Flag for : Bind the service into a shared isolated process. bindIso] (reference/androidicontent/Context#bindsolatedService(android.« ant BIND_WAIVE_PRIORITY (/reference/androidicontent/Context#BIND hitosvldeveloperandroll.comireferencelandoldlappiService 2403 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Flag for : don't impact the scheduling or memory management prio (ireferencefandroid/content/Context#tbindService(android.content. String (/referencejava/lang/String) pjoweTRIC_ SERVICE (/reference/androidicontent/Context#BIOMET Use with to retrieve a for handing biometric and PIN/pattern/passw (reference/android¢hardware/biometrics/BiometrieManager) String (/reference/javaltang/String) ay 06 STORE. SERVICE (/reference/androidicontent/Context#BLOB_ Use with to retrieve a for contributing and accessing data blobs fro (ireference/androidicontent’Contexti#getSystemService(java.lang.£ ‘String (/reference/javallang/StriNg) yeTooTH_ SERVICE (/referencelandroid/content/Context#BLUETC Use with to retrieve a for using Bluetooth. getSystemService( jav (Wreferencefandroidibluetooth/BluetoothManager) Sting (/reference/javallang/StriNg) syeRepoRT_ SERVICE (/referencefandroid/content/Context#BUGREF Service to capture @ bugreport. ‘String (/reference/javalang/Strin)caMeRA SERVICE (/reference/androidicontent/Context# CAMERA, SI Use with to retrieve a for interacting with camera devices. getSyst (Ireferencefandroid/hardware/camera2/CameraManager) ‘String (/reference/javalang/StriNg)¢apTTONING_ SERVICE (/reference/androidicontent/Context#CAPTI Use with to retrieve a for obtaining captioning properties and listeni (Wreference/androidicontent/Context#getSystemService(java.lang.£ String (/reference/javallang/String)carRTER CONFIG SERVICE (/reference/android/contentiContext#C Use with to retrieve a for reading cartier configuration values. getS (Ireferencefandroid/telephony/CarrierConfigManager) String (/reference/javallang/String)¢1 rpBOARD_SERVICE (/reference/android/content/Context##CLIPBC Use with to retrieve a for accessing and modifying the contents of (/referencefandroidicontent/ClipboardManager) hitosvldeveloperandroll.comireferencelandoldlappiService 251108 anv2i24, 1:90 PM Servigo [DesenvoWedores Android ‘String (/reference/javallang/St"iNg) compaNTON_DEVICE_ SERVICE (/reference/androidcontent/Contexti Use with to retrieve a for managing companion devices getSystem (ireference/androidicompanion/CompanionDeviceManager) Sting (/reference/javallang/String) counecTIVITY_ DIAGNOSTICS. SERVICE (/reference/android/conten Use with to retrieve a for performing network connectivity diagnost (reference/androidicontent/Context##getSystemService(java lang.< String (/reference/javallang/Strind) counecTIVITY_ SERVICE (/reference/androidicontent/Context#COt Use with to retrieve a for handling management of network connec (/referencefandroidinet/ConnectivityManager) ‘String (/reference/javalang/StriN) consuWER IR SERVICE (/reference/androidicontent/Context#!CON! Use with to retrieve a for transmitting infrared signals from the devi (Jreferencefandroid/hardware/ConsumerlrManager) ‘String (/reference/ava/lang/String) covract_ KEVS_ SERVICE (/reference/android/contentiContext#CO? Use with to retrieve a to managing contact keys. getSystemServi' (Wreference/androidiprovider/E2eeContactkeysManager) ant CONTEXT_IGNORE_SECURTTY (/reference/android/content/Context# Flag for use with : ignore any security restrictions on the Context bi (ireferencefandroid/content/Context#createPackageContext(java. int CONTEXT_INCLUDE_CODE (/reference/androidicontent/Context#COt Flag for use with : include the application code with the context. er int CONTEXT RESTRICTED (/reference/androidicontentContext#CONTI Flag for use with : a restricted context may disable specific feature String (/reference/javallang/StriNd) pReDENTIAL SERVICE (/reference/androidicontentiContext#CREDE hitosvldeveloperandroll.comireferencelandoldlappiService 26108 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Use with to retrieve a to authenticate a user to your app. getSyste (referencefandroidicredentials/CredentialManager) String (/reference/java/lang/String)cRoss PROFILE APPS SERVICE (/reference/androidicontent/Conte Use with to retrieve a for cross profile operations. getSystemServs (reference/androidicontent/pm/CrossProfileApps) int DEVICE_ID_DEFAULT (/reference/androidcontent/Context#DEVICE The default device ID, which is the ID of the primary (non-virtual) di int DEVICE _ID_INVALID (/reference/android/content/Context#DEVICE Invalid device ID. ‘String (/reference/ava/lang/String) perce Lock SERVICE (/reference/androidicontent/Context#DEVI: Use with to retrieve a . getSystemService( java.lang.String) ( Sting (/reference/javallang/SteiN@)pevice POL TCY_ SERVICE (/referencelandroidicontent/Context#DE Use with to retrieve a for working with global device policy manager (/reference/android/app/admin/DevicePolicyManager) String (/reference/javallang/StrinD)prsp1 ay HASH SERVICE (/reference/androidicontent/Context#DISI Use with to access to handle display hashes. getSystemService( (/referencefandroidiviewdisplayhash/DisplayHashManager) String (/reference/javalang/StriND)prsp1 ay_SERVICE (/reference/androidicontent/Contexti#DISPLAY £ Use with to retrieve a for interacting with display devices. getSyst« (Ireferencefandroidihardware/display/DisplayManager) ‘String (/reference/ava/lang/String)powary VERIFICATION. SERVICE (/reference/androidicontent/Cont Use with to access to retrieve approval and user state for declared DomainVerificationManager (/reference/android/content/pmiveri Sting (/reference/javallang/StriNg) pown oAD_SERVICE (/reference/android/content/Context#DOWNLC hitosvldeveloperandroll.comireferencelandoldlappiService 2mn0s anv2i24, 1:90 PM Servigo [DesenvoWedores Android Use with to retrieve a for requesting HTTP downloads. getSystemS (reference/android/app/DownloadManager) String (/reference/javallang/String) ppopBoX_ SERVICE (/reference/androidicontent/Context#DROPBOX Use with to retrieve a instance for recording diagnostic logs. getSy reference/androidios/DropBoxManager) String (/reference/javallang/StrinDeyice SERVICE (/reference/androidicontent/Context#EUICC_SERV Use with to retrieve a to manage the device eUICC (embedded SIM (ireference/androiditelephonyleuicc/EuiccManager) ‘String (/reference/javallang/Strin@)e7.¢ INTEGRITY SERVICE (/referencefandroidicontentiContext#F Use with to retrieve an . getSystemService( java.lang.String) ‘String (/reference/javallang/String) -1wceRPRINT_ SERVICE (/reference/androidicontent/Contexti#FING Use with to retrieve a for handling management of fingerprints. get (Wreferencefandroid/hardware/fingerprint/FingerprintManager) ‘String (/reference/javalang/String) sane. SERVICE (/referencefandroidicontent/Context#GAME_SERVIC Use with to retrieve a . getSystemService( java.lang.String) ( String (/reference/javallang/Steing) geaMMaTICAL INFLECTION_ SERVICE (/reference/androidicontentic Use with to retrieve a . getSystemService( java.lang.String) ( (Wreferencefandroid/app/GrammaticalinflectionManager) String (/reference/javallang/StriNg) saRoWARE. PROPERTIES. SERVICE (/referencefandroid/content/Cont Use with to retrieve a for accessing the hardware properties servic (reference fandroidios/HardwarePropertiesManager) ‘String (/reference/java/lang/String) He 4) THCONNECT. SERVICE (/reference/androidicontent/Context##HE Use with to retrieve a . getSystemService( java.lang.String) ( (Jreferencefandroidihealth/connect/HealthConnectManager) hitosvldeveloperandroll.comireferencelandoldlappiService 2803 anv2i24, 1:90 PM Servigo [DesenvoWedores Android ‘Sting (/reference/javallang/Steing) rypyt_METHOD_ SERVICE (/reference/androidicontent/Context#INP! Use with to retrieve a for accessing input methods. getSystemSer’ (Wreference/androidiviewinputmethodiinputMethodManager) ‘String (reference/java/lang/String) ~wpyr_sERVICE (/reference/androidicontent/Context#INPUT_SERV Use with to retrieve a for interacting with input devices. getSystem (reference/androidihardware/nput/InputManager) String ((referencejavallang/String)ypsec SERVICE (/reference/androidicontent/Contexti#IPSEC_SERVI Use with to retrieve a for encrypting Sockets or Networks with IPSe (/referencefandroidinet/IpSecManager) ‘String (/referencejava/lang/String) om scHEDULER SERVICE (/reference/androidicontent/Context#JO Use with to retrieve a instance for managing occasional backgroun (Ireferencefandroid/app/jobUobScheduler) ‘String (/reference/ava/lang/String) evayaRD_ SERVICE (/reference/androidicontent/Context#KEYGUAT Use with to retrieve a for controling keyguard. getSystemService (Wreferencefandroid/app/KeyguardManager) String (/reference/javalang/String), ayNcHER_APPS_ SERVICE (/referencefandroidicontent/Context#LA Use with to retrieve a for querying and monitoring launchable apps (ireferencefandroid/content/pm/LauncherApps) String (/reference/javalang/String), avout INFLATER SERVICE (/reference/androidicontent/Contextit Use with to retrieve a for inflating layout resources in this context. (/referencefandroidiviewLayoutinflater) String (/reference/javalang/String), Ocal E SERVICE (/reference/androidicontent/Context#LOCALE.St Use with to retrieve a . getSystemService( java.lang.String) ( Sting (/reference/javallang/String), gear TON SERVICE (/reference/android/content/Context#LOCATIC hitosvldeveloperandroll.comireferencelandoldlappiService 2anos anv2i24, 1:90 PM Servigo [DesenvoWedores Android Use with to retrieve a for controlling location updates. getSystemS (referencefandroidlocation/LocationManager) ‘String (/reference/java/lang/Strin@) wep, COMMUNICATION. SERVICE (/referencefandroidicontent/Cont Use with to retrieve a for managing . getSystemService(java.la (Ireferencefandroidimedia/MediaCommunicationManager)MediaSe String (/reference/avallang/String) went, WETRICS SERVICE (/referencefandroidicontent/Context##ME Use with to retrieve a for interacting with media metrics on the dev (ireference/androidimediamnetrics/MediaMetricsManager) String (/reference/javallang/Stri@ wep, PROJECTION. SERVICE (/reference/androidicontent/Contexti Use with to retrieve a instance for managing media projection sess (Wreferencefandroidimedia/projection/MediaProjectionManager) Sting (/reference/javallang/Strin@)wepr, ROUTER SERVICE (/reference/androidicontent/Context#MEL Use with to retrieve a for controlling and managing routing of medi (eferenceandroidimedia/MediaRouter) String (/referencejava/lang/Stting) wera SESSION SERVICE (/reference/androidicontent/Contexti#ME Use with to retrieve a for managing media Sessions. getSystemSer (Wreferencefandroidimedia‘session/MediaSessionManager) String (/referencejavaliang/String)wrpy_ SERVICE (/reference/androidicontent/Context#MIDI_SERVICE Use with to retrieve a for accessing the MIDI service. getSystemSe (Ireferencefandroidimediafmidi/MidiManager) ant MODE_APPEND (/reference/androidcontent/Context#MODE_APPEN File creation mode: for use with , if the file already exists then write (ireferencefandroid/content/Context#openFileOutput(java.lang.Stri int MODE ENABLE WRITE AHEAD LOGGING (/reference/android/content, Database open flag: when set, the database is opened with write-a hitosvldeveloperandroll.comireferencelandoldlappiService son03 sari24, 1:90 Servge [Desenvolvedores Android ant MODE_MULTI_PROCESS (/reference/android/content/Context#MODE This constant was deprecated in API level 23. MODE_MULTI_PROC processes. Applications should not attempt to use it. Instead, they ant MODE_NO_LOCALTZED_COLLATORS (/reference/android/content/Cont Database open flag: when set, the database is opened without sup int MODE_PRIVATE (/reference/android/content/Context#MODE_PRIVAT File creation mode: the default mode, where the created file can or ant MODE_WORLD_READABLE (/reference/androidicontent/Context#MOD This constant was deprecated in API level 17 Creating world-readat mechanism for interactions such as ContentProvider (/reference There are no guarantees that this access mode will remain on a file ant MODE_WORLD_WRITEABLE (/reference/androidicontent/Context#MO1 This constant was deprecated in API level 17 Creating world-writabi mechanism for interactions such as ContentProvider (/reference There are no guarantees that this access mode will remain on a file Sting (/reference/javallang/Stei@ werwork_STATS_ SERVICE (/referencelandroid/content/Contexti#NE Use with to retrieve a for querying network usage stats. getSyster (Ireferencefandroid/appfusage/NetworkStatsManager) String (/reference/javalang/Strind yee. seaVICE (ireferencefandroid/content/Context##NFC_SERVICE) Use with to retrieve a for using NFC. getSystemService( java.la String (/reference/javallang/Stri@ wor pe TCATION_ SERVICE (/reference/androidicontent/Context#NO1 Use with to retrieve a for informing the user of background events. (Wreferencefandroid/app/NotificationManager) ‘String (/reference/java/lang/String)ysp_seRVICE (/reference/androidicontent/Context#NSD_SERVICE) hitosvldeveloperandroll.comireferencelandoldlappiService si0s anv2i24, 1:90 PM Servigo [DesenvoWedores Android Use with to retrieve a for handling management of network service (teference/androidinetnsdiNsdManager) String (/reference/javallang/String) over ay_SERVICE (/reference/androidicontent/Context#OVERLAY_ Use with to retrieve a for managing overlay packages. getSystemS (ireferencefandroid/contentiom/OverlayManager) String (/reference/javalang/StriN9) peop e SERVICE (/reference/androidicontent/Context# PEOPLE_SE Use with to access a to interact with your published conversations. (/referencefandroid/app/people/PeopleManager) ‘String (/reference/javallang/StriNg) peRFORMANCE_HINT_ SERVICE (/reference/androidicontent/Contexti Use with to retrieve a for accessing the performance hinting servic (Wreferencefandroidios/PerformanceHintManager) ‘String (/reference/java/lang/String) pqweR SERVICE (/reference/androidicontent/Contexti#POWER SER Use with to retrieve a for controlling power management, including (/reference/androidicontent/Context#getSystemService(java.lang.< String ((referencejavaliang/String) peiNT_SERVICE (Ireference/androidicontent/Contexti#PRINT_SERVI PrintManager (/reference/android/print/PrintManager) for printing ‘String (/referencefava/lang/String), PROFILING _ SERVICE (/reference/androidicontent/Context#PROFIL Use with to retrieve an . getSystemService( java.lang.String) int RECEIVER_EXPORTED (/reference/androidicontent/Contexti#RECEIV| Flag for : The receiver can receive broadcasts from other Apps. ret (referencefandroidicontent/Context#registerReceiver(android.con int RECEIVER_NOT_EXPORTED (/reference/android/content/Context#RE Flag for : The receiver cannot receive broadcasts from other Apps. (ireferencefandroidicontent/Context#registerReceiver(android.con hitosvldeveloperandroll.comireferencelandoldlappiService 20s anaes, 130° Servo [Desenvohedore Android int RECEIVER VISIGLE_TO_INSTANT_APPS (/reference/androidiconten Flag for : The receiver can receive broadcasts from Instant Apps. © (ireference/androidicontent’Context#registerReceiver(android.con String (/reference/javalang/String) pesrRICTIONS. SERVICE (/reference/android/content/Context#RES Use with to retrieve a for retrieving application restrictions and reat (reference/androidicontent/Context#tgetSystemService (java lang. String (/referencejavallang/String)pove_ SERVICE (/reference/androidicontent/Context#ROLE_SERVIC Use with to retrieve a for managing roles. getSystemService(jav String ((reference/javafiang/Sting)seancy SERVICE (/reference/androidicontent/Context#SEARCH_SE Use with to retrieve a for handling searches. getSystemService(j String (/reference/java/lang/String) securrTy_ STATE SERVICE (/reference/android/content/Contexti#S Use with to retrieve a for accessing the security state manager ser (ireferencefandroid/os/SecurityStateManager) String (/reference/javalang/String) seusoR SERVICE (/reference/androidicontent/Context#SENSOR_SE Use with to retrieve a for accessing sensors. getSystemService(: reference/android-hardware/SensorManager) String (/reference/javallang/StriNg) sort cuT_SERVICE (/reference/android/content/Context#SHORTC! Use with to retrieve a for accessing the launcher shortcut service. (Wreferencefandroidicontent/pm/ShortcutManager) String (/reference/java/lang/String), 'STATUS_BAR_SERVICE (/reference/android/content/Context#STATU Use with to retrieve a for interacting with the status bar and quick < (reference/android/app/StatusBarManager) String (/reference/javallang/Strind) sroRaGE_ SERVICE (/reference/androidicontent/Contexti# STORAGE, hitosvldeveloperandroll.comireferencelandoldlappiService 303 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Use with to retrieve a for accessing system storage functions. get! (reference/androidiosistorage/StorageManager) ‘String (/reference/java/lang/Stting) stoaGe STATS. SERVICE (/reference/androidicontent/Contexti#ST Use with to retrieve a for accessing system storage statistics. gets (reference/android/apptisage/StorageStatsManager) ‘String (/reference/javalang/Strind) sysTew HEALTH SERVICE (/referencefandroidicontentiContext#SY Use with to retrieve a for accessing system health (battery, power, ‘SystenHieal thManager (/reference/androidoshhealth/SystemHealtt ‘String (/reference/javalang/String) re. Ecom_ SERVICE (/reference/android/content/Context# TELECOM Use with to retrieve a to manage telecom-related features of the d (Ireferencefandroiditelecom/TelecomManager) String (/reference/javalang/String) re EPHONY._ IMS_ SERVICE (/referencefandroidicontent/Context#TE Use with to retrieve an . getSystemService( java.lang.String) ‘String (/reference/java/lang/String) re epHoNY_ SERVICE (/reference/androidicontent/Context#TELEPH Use with to retrieve a for handling management the telephony feati reference/androiditelephony/TelephonyManager) ‘String (/reference/javallang/StriNg) 1 EPHONY_SUBSCRIPTION_ SERVICE (/reference/androidicontentiC Use with to retrieve a for handling management the telephony subs SubscriptionManager (/reference/android/telephony/Subscription| String (/reference/javallang/String) rex7_ cL ASSIFICATION_ SERVICE (/referencefandroidicontent/Cont Use with to retrieve a for text classification services. getSystemSe (referencefandroidiview!textclassifier/TextClassificationManager) String (/reference/javallang/Steing)rex7_ SERVICES MANAGER SERVICE (/reference/androidicontentiCc Use with to retrieve a for accessing text services. getSystemServ: (/referencefandroidiview'textservice/TextServicesManager) hitosvldeveloperandroll.comireferencelandoldlappiService anos anv2i24, 1:90 PM Servigo [DesenvoWedores Android ‘String (/reference/javallang/String)ry twpuT_SERVICE (/reference/android/content/Context#TV_INPU Use with to retrieve a for interacting with TV inputs on the device. ¢ (reference/androidimediaytw/TvinputManager) String (/reference/javallang/Steing\ry TwreRACTIVE_APP_ SERVICE (/reference/android/content/Conte Use with to retrieve a for interacting with TV interactive application: IvInteractivesppManager (/reference/androidmediaytvinteractiv String (/reference/javallang/StrinD\yr_ ope SERVICE (/reference/androidicontent/Contexti#U|_MODE_ Use with to retrieve a for controlling Ul modes. getSystemService String ((reference/javaliang/Stind)ysace STATS SERVICE (/reference/androidiconten/Context#USAC Use with to retrieve a for querying device usage stats. getSystemS (Wreferencefandroid/apphisage/UsageStatsManager) ‘String (Ireference/javallang/String)ysg SERVICE (/reference/androidicontent/Contexti#USB_SERVICE) Use with to retrieve a for access to USB devices (as a USB host) ar (reference/androidicontent/Context#tgetSystemService(java.lang. String (referencejavallang/String)yser SERVICE (/reference/androidicontent/Context#USER_SERVIC Use with to retrieve a for managing users on devices that support r (Wreferencefandroidios/UserManager) ‘String (/reference/java/lang/String) vrpeaTOR MANAGER. SERVICE (/reference/androidicontent/Context: Use with to retrieve a for accessing the device vibrators, interactin: (/referencefandroidicontent/Context#getSystemService(java.lang.£ String (/reference/javalang/String)yyeeaToR SERVICE (/reference/android/content/Context#VIBRATO This constant was deprecated in API level 31. Use VibratorManage String (/reference/javalang/StrinD vigTyAL DEVICE SERVICE (/reference/androidicontentiContext#V hitosvldeveloperandroll.comireferencelandoldlappiService 35/103 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Use with to retrieve a for managing virtual devices. getSystemSery (/reference/android/companion/virtual/VirtualDeviceManager) ‘String (/reference/java/lang/Stting) yew MANAGEMENT. SERVICE (/reference/android/content/Contexti#V Use with to retrieve a to manage profiles for the platform built-in VE (/referencefandroidinet/pnManager) ‘String (/reference/javalang/StriND wal PAPER SERVICE (/referencefandroidicontentiContext#WALLP/ Use with to retrieve a com. android. server WallpaperService for acct String (Wreference/javallang/StriD wiry AWARE SERVICE (/reference/androidicontentiContext#WIFI_# Use with to retrieve a for handling management of Wi-Fi Aware. get (/reference/androidinet/wifiaware/WifiAwareManager) String (/reference/javallang/StrinDwrey pap SERVICE (/reference/android/content/ContextitWIF|_P2F Use with to retrieve a for handling management of Wi-Fi peer-to-pe (ireferencefandroidinet/wififp2p/WifiP2pManager) ‘String (/reference/ava/lang/String)wrey RTT RANGING. SERVICE (/reference/androidicontent/Context: Use with to retrieve a for ranging devices with wif. get SystenServ reference/androidnetwifirttwifikttManager) String ((reference/javafiang/Sting)wrey_ SERVICE (/reference/androidiconten/Context#WIFI_ SERVICE Use with to retrieve a for handling management of Wi-Fi access. g¢ (Wreferencefandroidinet/wifiWifiManager) String (/reference/java/lang/String)MINDOW_SERVICE (/reference/androidicontent/Context#WINDOW_$ Use with to retrieve a for accessing the system's window manager. (IreferencefandroidiviewWindowManager) From interface android. content. ComponentCal lbacks? (/reference/android/content/ComponentC int ‘TRIM_MEMORY_BACKGROUND (/reference/android/content/ComponentC: Level for : the process has gone on to the LRU list. onTrimMemory (ir hitosvldeveloperandroll.comireferencelandoldlappiService 6103 anv2i24, 1:90 PM int int int int int int Public constructors Servigo [DesenvoWedores Android ‘TRIM_MEMORY COMPLETE (/reference/androidicontent/ComponentCallt Level for : the process is nearing the end of the background LRU list, : ‘TRIM_MEMORY_MODERATE (/reference/androidicontent/ComponentCallt Level for : the process is around the middle of the background LRU lis. (reference/androidicontent/ComponentCallbacks2#onTrimMemory(ir ‘TRIM_MEMORY RUNNING CRITICAL (/reference/androidicontent/Comp Level for : the process is not an expendable background process, but (Wreferencefandroidicontent/ComponentCallbacks2#onTrimMemory(ir TRIM MEMORY RUNNING LOW (/reference/android/content/Component( Level for : the process is not an expendable background process, but ‘TRIM_MEMORY_ RUNNING MODERATE (/reference/androidicontent/Comp Level for : the process is not an expendable background process, but ‘TRIM_MEMORY_UL HIDDEN (/reference/androidicontent/ComponentCal Level for : the process had been showing a user interface, and is no k Service (/reference/android/app/Servicei#Service())() Public methods final Application getApplicatiion (/reference/androidappiServicettgetApplication())( (Jreferencefandroid/app/Application) Return the application that owns this service. hitosvldeveloperandroll.comireferencelandoldlappiService srn0s anv2i24, 1:90 PM final int abstract [Binder (IreferencefandroidosiBinder) void void void void void Servigo [DesenvoWedores Android getForegroundServiceType (/reference/androidlapp/Service#getFc 0 If the service has become a foreground service by calling or , returns service type. startForeground(int, android jotificatio (ireference/android/app/Service#startForeground(int, %20android.ap startForeground(int,_android jotification, int) (ireference/androidapp/ServicestartForeground(int,%20android.ap getForegroundServiceType() (ireference/android/app/Service#getF oregroundServiceType()) onBind (/reference/android/app/ServicettonBind(android.content.inte (ireference/androidicontent/intent) intent) Return the communication channel to the service. onConfigurationChanged (Ireference/android/app/Service#tonConfigurationChanged(android.c (Configuration (/reference/androidicontentires/Configuration) nev Called by the system when the device configuration changes while yi onCreate (/reference/android/app/Service#onCreate()) () Called by the system when the service is first created, onDestroy (/reference/android/app/Servicet# onDestroy()) () Called by the system to notify a Service that itis no longer used and onLowMemory (/reference/android/app/Service#onLowMemory())() This is called when the overall system is running low on memory, and processes should trim their memory usage. onRebind (/reference/android/app/Service#onRebind(android.conten (ireference/androidicontentiintent) intent) Called when new clients have connected to the service, after it had } that all had disconnected in its . onUnbind (Intent) (ireference/android/app/ServicettonUnbind(android.content.Intent)) hitosvldeveloperandroll.comireferencelandoldlappiService e083 anv2i24, 1:90 PM void int void void void boolean final void Servigo [DesenvoWedores Android onStart (/reference/android/app/Service #onStart(android.content.n (ireference/androidicontent/intent) intent, int startId) This method was deprecated in API level 15. Implement onStartCommand(android.content.Intent,_int,_int) (Ireference/android/app/Service#onStartCommand(android.content. instead. onStartCommand (ireference/android/app/Service#tonStartCommand(android.content. (Intent (/reference/androidicontent/intent) intent, int flags, Called by the system every time a client explicitly starts the service t arguments it supplied and a unique integer token representing the st Context. startService(Intent) (/reference/androidicontent/Context#startService(android.content.lt onTaskRemoved (/reference/androidiapp/Service#onTaskRemoved(ar (Intent (/reference/androidicontent/intent) rootIntent) This is called if the service is currently running and the user has rem from the service's application. onTimeout (/reference/android/app/Service#onTimeout(int))(int st Callback called on timeout for . ServiceTnfofFOREGROUND_SERVICt (Ireference/androidicontent/pm/Servicelnfo#tF OREGROUND_SERVIC! onTrimMemory (/reference/android/app/Ser ice#onTrimMemory(int)) Called when the operating system has determined that it is a good ti unneeded memory from its process. onUnbind (/reference/android/app/ServicetonUnbind(android.conter (Ireference/android/content/intent) intent) Called when all clients have disconnected from a particular interface startForeground (ireference/android/app/ServiceitstartForeground(int, %20android.ap_ Notification (/reference/android/appiNotification) notification hitosvldeveloperandroll.comireferencelandoldlappiService anos anv2i24, 1:90 PM final void final void final void final void final void final boolean Servigo [DesenvoWedores Android If your service is started (running through ), then also make this serv supplying the ongoing notification to be shown to the user while in th Context#startService(Intent) (/reference/android/content/Context#startService(android.content.11 startForeground (ireference/android/app/Service##startForeground(int, %20android. ap (int id, Notification (/reference/android/app/Notification) not: foregroundServiceType) ‘An overloaded version of with additional foregroundServiceType para startForeground(int,_android. app.Notification) (ireference/android/app/ServicettstartForeground(int, %20android.ap stopForeground (/reference/androidlapp/Service##stopForeground(it notificationBehavior) Remove this service from foreground state, allowing it to be killed if n stopForeground (/reference/android/app/ServicettstopForeground(t removeNotification) This method was deprecated in API level 33. call stopForeground( i (Ireference/android/app/Servicet#stopForeground{int)) and pass eithy ‘STOP_FOREGROUND_RENOVE (/reference/android/app/Service#STOP_F or STOP_FOREGROUND_DETACH (ireference/android/app/Service#STOP_FOREGROUND_DETACH) ext stopSelf (/reference/android/app/Service##stopSelf())() Stop the service, if it was previously started. stopSelf (/reference/android/app/Service#stopSelf(int)) (int start Old version of that doesn't return a result. stopSelfResult (int) (reference/android/app/Service##stopSelfResult(int)) stopSelfResult (/reference/android/app/ServicettstopSelfResult(int Stop the service if the most recent time it was started was . startid hitosvldeveloperandroll.comireferencelandoldlappiService 40/103 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Protected methods voidattachBaseContext (/reference/android/app/ServicettattachBaseContext(android.content.Context) (Context (reference/androidicontent/Context) newBase) Set the base context for this ContextWrapper. voiddump (ireference/android/app/Service## dump(java.io.FileDescriptor,%20java.io.PrintWriter,%20java.lang.St (EileDescriptor (/reference/javafo/FileDescriptor) fd, PrintWriter (/reference/javafo/PrintWri writer, String[] (/reference/java/lang/String) args) Print the Service's state into the given stream, Inherited methods i per (/reference/androidicontent/ContextWrapper) attachBaseContext (/reference Set the base context for this Cor boolean bindIsolatedService (/referer int flags, String (/reference Variation of that, in the specific « (ireference/androidicontentiCor boolean bindService (/reference/androi (reference/javalutiveoncurrent/| ‘Same as with executor to contro boolean bindService (/reference/androi (referencefandroidicontent/Ser See Call to obtain a BindServicet BindServiceFlags#of (long) ( hitosvldeveloperandroll.comireferencelandoldlappiService ans anv2i24, 1:90 PM Servigo [DesenvoWedores Android boolean bindService (/reference/androi conn, int flags) Connects to an application servi boolean bindService (/reference/androi service, Context.BindServi See Call to obtain a BindServicet (ireferencefandroidicontent/Cor int checkCallingOrSelfPermissi Determine whether the calling pr int checkCallingOrselfUriPermi Determine whether the calling pr int{] checkCallingOrSelfUriPermi Determine whether the calling pr int checkCallingPermission (ref Determine whether the calling pr int checkCallingUriPermission ( Determine whether the calling pr int[] checkCallingUriPermissions Determine whether the calling pr ant checkPermission (/reference/a Determine whether the given pe! int checkSelfPermission (/referer hitosvldeveloperandroll.comireferencelandoldlappiService 42/03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Determine whether you have ber aint checkUriPermission (/referenc String (/reference/java/lang/Str Check both a Uri and normal per ant checkUriPermission (/referenc Determine whether a particular 5 int{] checkUriPermissions (/referer Determine whether a particular ¢ void clearWallpaper (/reference/an This method is deprecated. Use This method requires the caller t Context (/reference/android/content/Context) createAttributionContext (/1 Return a new Context object for Context (/reference/android/content/Context) createConfigurationcontext Return a new Context object for Context (/reference/android/content/Context) oreateContext (/reference/and Creates a context with specific 5 Context (/reference/android/content/Context) createDeviceContext (/referet Returns a new object from the ci Context (/reference/android/content/Context) createDeviceProtectedStora Return a new Context object for hitosvldeveloperandroll.comireferencelandoldlappiService 43/03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Context (/reference/android/content/Context) createDisplayContext (/refere Returns a new object from the ci Context (/reference/android/content/Context) createPackageContext (/refere Return a new Context object for Context (/reference/android/content/Context) createWindowContext (/referer Creates a Context for a non-act Context (/reference/android/content/Context) createWindowContext (/referer Creates a for a non- window on + Stringl (reference/javafang/String) databaseList (/reference/andre Returns an array of strings namit boolean deleteDatabase (/reference/an Delete an existing private SQLite boolean deleteFile (/reference/android. Delete the given private file assc boolean deleteSharedPreferences (/re Delete an existing shared prefer vold enforceCallingOrSelfPermis If neither you nor the calling proc void enforceCallingOrSelfUriPer message) If the calling process of an IPC c hitosvldeveloperandroll.comireferencelandoldlappiService anos anv2i24, 1:90 PM Servigo [DesenvoWedores Android void void void void void String| ] (/reference/java/lang/String) Context (/reference/android/content/Context) ApplicationInfo (/reference/android/content/pm/Applicationinfo) AssetManager (/reference/android/content/res/AssetManager) nSource (/reference/androidicontentAttributionSource) hitosvldeveloperandroll.comireferencelandoldlappiService enforceCallingPermission (/1 If the calling process of an IPC y enforceCallingUriPermissio If the calling process and uid ha: enforcePermission (/reference If the given permission is not alle enforceUriPermission (/refere readPermission, String (/ref Enforce both a Uri and normal pr enforceUriPermission (/refere message) Ifa particular process and uid he fileList (/reference/androidicc Returns an array of strings namit getApplicationContext (/refe Return the context of the single, getApplicationInfo (/referenc Return the full application info fo getAssets (/referencelandroidic Returns an AssetManager instan getAttributionSource (/refere 45/103 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Context (/reference/android/content/Context) File (/reference/javafo/File) ClassLoader (/reference/java/lang/ClassLoader) File (/reference/javafo/File) ContentResolver (/reference/androidicontent/ContentResolver) File (reference/javafo/File) File (/reference/javaho/File) int File (/reference/javafo/File) Display (/reference/android/view/Display) File (/reference/javaho/File) hitosvldeveloperandroll.comireferencelandoldlappiService getBaseContext (/reference/an getCacheDir (/reference/androi Returns the absolute path to the getClassLoader (/reference/an Retum a class loader you can us getCodeCacheDir (/referencela Returns the absolute path to the getContentResolver (/referenc Return a ContentResolver instan getDataDir (/reference/android Returns the absolute path to the getDatabasePath (/reference/a Returns the absolute path on the (Ireferencefandroidicontent/Cor getDeviceld (/reference/androi Gets the device ID this context i: getDir (/reference/androidicont Retrieve, creating if needed, a nc getDisplay (/reference/android. Get the display this context is as getExternalCacheDir (/referer 46103 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Filel_] (/reference/javafo/File) File (/reference/javafo/File) File[ ] (/reference/javafo/File) File] (/reference/javafo/File) File (/referencefjavahorFile) File (/reference/javafo/File) Executor (/reference/javaiuti/eoncurrenvExecutor) Looper (/reference/android/os/Looper) File (/reference/javahoiFile) File (/reference/javafo/File) hitosvldeveloperandroll.comireferencelandoldlappiService Returns absolute path to applica getExternalCacheDirs (/refere Returns absolute paths to applic getExternalFilesDir (/referer Returns the absolute path to the getExternalFilesDirs (/refere Returns absolute paths to applic getExternalMediaDirs (/refere This method is deprecated. Thes (referencefandroid/provider/Me: getFileStreamPath (reference Returns the absolute path on the getFilesDir (/reference/androi Retums the absolute path to the getHainExecutor (/referencela Return an that will run enqueued getHlainLooper (/reference/and Return the Looper for the main t getNoBackupFilesDir (/referer Returns the absolute path to the getObbDir (reference/androidie amos anv2i24, 1:90 PM Servigo [DesenvoWedores Android Return the primary shared/exterr Filel.] (referencejavaforile) getObbDirs (/reference/android Returns absolute paths to applic String (/reference/java/lang/String) etPackageCodePath (/referenc Return the full path to this conte PackageManager (/reference/androidicontent/pm/PackageManager) setpackageanager (Ireference Return PackageManager instanc ‘String (/reference/java/lang/String) getPackageNane (/reference/an Return the name of this applicati ‘String (/reference/java/lang/String) stPackageResourcePath (iret getPackageResourcePath Return the full path to this conte ContextParams (/reference/androidicontent/ContextParams) etParams (/reference/androidic Return the set of parameters wh Resources (/reference/android/content/res/Resources) etResources (/reference/andre getResources Returns a Resources instance fo SharedPreferences (/reference/androidicontent/sharedPreferences) geesharedPreferences (/refert Retrieve and hold the contents Object (/reference/javallang/Object) getSystemService (/reference/ Return the handle to a system-le String (/reference/java/lang/String) getSystenServicelame (referc hitosvldeveloperandroll.comireferencelandoldlappiService 48/03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Gets the name of the system-lev Resources. Thene (/reference/androidicontentires/Resources.TheMe) aoe theme (/reference/androidice Retum the Theme object associe Drawable (/referencefandroidigraphics/drawable/Drawable) etal Ipaper (/reference/andrc This method is deprecated. Use int etal lpaperDesiredMinimun This method is deprecated. Use int getWallpaperDesiredMinimun This method is deprecated. Use void grantUriPermission (/referenc Grant permission to access a sp boolean isDeviceProtectedStorage (/t Indicates if the storage APIs of t boolean isRestricted (/reference/andre Indicates whether this Context i boolean moveDatabaseFrom (/reference/ Move an existing database file fr boolean moveSharedPreferencesFrom ( Move an existing shared prefere EileInputStream (/reference/javafo/FilelnputStream) open iletnput (/referencefand hitosvldeveloperandroll.comireferencelandoldlappiService 49/03 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Open a private file associated wi FileOutputStream (/reference/javafo/FileOutputStream) openFileOutput (referencefan Open a private file associated wi ‘SOLiteDatabase (/reference/androidiatabasersaite/SQL iteDatabase) op enor createDatabase (irefert int mode, SQLiteDatabase.C Open a new private SQLiteDatak ‘SQLiteDatabase (/reference/androididatabase/sqlite/SQLiteDatabase) op enorcreatedatabase (/tefere SQLiteDatabase.CursorFacto Open a new private SQLiteDatak Drawable (/reference/android/graphics/drawable/Drawable) peekWallnaper (/referencefand This method is deprecated. Use void registerComponentCallbacks Add a new to the base applicatic void registerDeviceldChangeList (reference/javaiutilfunction/int! Adds a new device ID changed li Intent (/reference/androidicontent/intent) registerReceiver (/reference! (referencefandroidicontent/inte Register a BroadcastReceiver to Intent (/reference/android/content/intent) registerReceiver (reference/ (referencefandroidicontent/inte Register to receive intent broadc Intent (/reference/android/eontent/Intent) registerReceiver (/reference/ (Ureferencefandroidicontent/Bro: hitosvldeveloperandroll.comireferencelandoldlappiService 50/103 anv2i24, 1:90 PM Intent (/reference/android/content/Intent) void void void void void void void void hitosvldeveloperandroll.comireferencelandoldlappiService Servigo [DesenvoWedores Android Register to receive intent broad registerReceiver (reference! receiver, IntentFilter (/ref Register to receive intent broade removeStickyBroadcast (/refe This method is deprecated. Stick has changed, with another mect removeStickyBroadcastAsUse user) This method is deprecated. Stick has changed, with another mect revokeSelfPermissionsOnKil Triggers the revocation of one ot revokeUriPermission (/referer Remove all permissions to acces revokeUriPermission (/referer Remove permissions to access @ (referencefandroidicontent/Cor sendBroadeast (/reference/and (referencefandroidios/Bundle) « Broadcast the given intent to all sendBroadcast (/reference/and Broadcast the given intent to all sendBroadcast (/reference/and 5103 anv2i24, 1:90 PM Servigo [DesenvoWedores Android Broadcast the given intent to all void sendBroadcastAsUser (/referer Version of that allows you to spe void sendBroadcastAsUser (/referer user, String (/reference/javall Version of that allows you to spe void sendOrderedBroadcast (Ireferencefandroidicontent/Cor (referencefandroidicontent/inte (referencefandroidios/Handler) Version of that allows you to spe java. lang.String,_androis void sendOrderedBroadcast (reference/androidicontentiCor (Intent (reference/androidicor resultReceiver, Handler (/re void sendOrderedBroadcast (/refere (Ireferencefandroidicontent/inte initialCode, String (/referer Version of that allows you to rec: void sendOrderedBroadcast (/refere receiverPermission, Bundle Broadcast the given intent to all void sendOrderedBroadcast (referencefandroidicontent/Cor (referencefandroidicontent/inte (referencefandroidios/Handler) Version of that allows you to rect hitosvldeveloperandroll.comireferencelandoldlappiService 52/108 anv2i24, 1:90 PM Servigo [DesenvoWedores Android void sendOrderedBroadcast (/refere Broadcast the given intent to all void sendOrderedBroadcastAsUser (referencefandroidicontent/Cor (Intent (/reference/androidicor Handler (/reference/androidios/t Version of that allows you to spe android.os. Bundle) (/referenc void sendStickyBroadcast (/referer This method is deprecated, Stick has changed, with another mect void sendStickyBroadcast (/referer This method is deprecated. Stick has changed, with another mect void sendStickyBroadcastAsUser ( This method is deprecated. Stick has changed, with another mect void sendStickyOrderedBroadcast (reference/androidicontent/inte Bundle (/reference/android/os/B1 This method is deprecated. Stick has changed, with another mect void sendStickyOrderedBroadcast (referencefandroidicontent/Cor (referencefandroidicontent/inte String (/reference/javallang/Str This method is deprecated. Stick has changed, with another mect hitosvldeveloperandroll.comireferencelandoldlappiService 53108 anv2i24, 1:90 PM Servigo [DesenvoWedores Android void void void void void void void ComponentNane (/reference/androidicontent/ComponentName) boolean hitosvldeveloperandroll.comireferencelandoldlappiService setThene (/reference/androidicc Set the base theme for this cont setWal paper (/reference/andrc This method is deprecated. Use This method requires the caller t setWallpaper (/reference/andrc This method is deprecated. Use This method requires the caller t startAct: es (/reference/a Launch multiple new activities. startActivities (/reference/a ‘Same as with no options specifie startActivity (/reference/and ‘Same as with no options specifie startActivity (/reference/and Launch a new activity. startForegroundService (/ref Similar to , but with an implicit pr (Wreferencefandroid/app/Service: startInstrunentation (/referc (/reference/java/lang/String) pr Start executing an class. Instrt 54/103 anv2i24, 1:90 PM Servigo [DesenvoWedores Android void void ComponentNane (/reference/androidicontent/ComponentName) boolean void void void void void hitosvldeveloperandroll.comireferencelandoldlappiService startIntentSender (/reference (referencefandroidicontent/inte ‘Same as with no options specifie (referencefandroidicontent/Cor startIntentSender (/reference (referencefandroidicontent/inte Like , but taking a IntentSender 1 startService (/reference/andrc Request that a given application stopService (/reference/androi Request that a given application unbindService (/reference/and Disconnect from an application « unregisterComponentCallbac Remove a object that was previo (referencefandroidicontent/Cor unregisterDeviceldChangeLi Removes a device ID changed lis unregisterReceiver (/referenc Unregister a previously registere (ireferenc For a service previously bound w (referencefandroidicontent/Cor 55/108

You might also like