AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
![]() Now we add other lifecycle methods of the MyService: onCreate()onStart()onDestroy() We’ll also need to add the Service in AndroidMenifest.xml4. We’ll add a new class MyServicethat extends Service. ServiceService ExampleWe’ll create a simple ServiceDemo application which runs in background and shows notification in the upper Notification Bar with a period of specified timeWe create a project with following:Project Name: ServiceDemoBuild Target: 1.6Application name:ServiceDemoPackage name: Activity:ServiceDemoActivityMin SDK Version: 4 ![]() Main Features of Serviceto tell the system about something it wants to be doing in the background (even when the user is not directly interacting with the application)to calls to Context.startService(), which ask the system to schedule work for the service, to be run until the service or someone else explicitly stop it. It is not a means itself to do work off of the main thread (to avoid Application Not Responding errors). The Service object itself does not imply it isrunning in its own process unless otherwise specified, it runs in the same process as the application it is part of. ServiceWhat a Service is NOT?There are some confusions:A Service is not a separate process. ServiceWhat is Service?Services are codes that run in the backgroundThey can be started and stoppedServices doesn’t have UIstartService()Audio ServicePlays AudiostopService()Audio Player UI Android Application DevelopmentServiceAhsanul Solutions Ltd.Īndroid Application AnatomyActivitiesProvides User InterfaceUsually represents a Single ScreenCan contain one/more ViewsExtendsthe Activity Base classServicesNoUser InterfaceRuns in BackgroundExtends the Service Base ClassIntent/Broadcast ReceiverReceives and Reacts to broadcast IntentsNo UI but can start an ActivityExtends the BroadcastReceiver Base ClassContent ProviderMakes application data available to other appsData stored in SQLite databaseExtends the ContentProviderBase classApplication= Set of Android Components
0 Comments
Read More
Leave a Reply. |