GTU Android Program 9 Android Service Example

GTU Android Program 9 Android Service Example Create an background application that will open activity on specific time.

GTU Android Program 9

Android Service is the same as Activity but it don’t have interface. Some task need to be repeated many time and frequently in this kind of situation we need to use the Android Service. Android service is the best way to execute on background when its required. For example you setup alarm of morning and in morning alarm will automatically starts, that’s magic of Android Service.

Step 1 : Create New Android Project

Step 2 : Add New Java File (Which we are going to create Service, Remember only java File Not Activity)

Step 3 : Write down code in Service File

Step 4 : Register Your service into AndroidManifest.xml sothat we can call service.

Step 5 : Add 2 button in your main activity to start/stop service.

Check out the complete code of the Android Service Example.

Question related with android service.

  • Differentiate Activity and Service
  • Explain android service.
  • write down code snippet of android service.

 

Location : res\layout

FileName: activity_main.xml

 

Location : src\package\

FileName : MainActivity.java

 

Continue Reading…

 

 

Adarsh Patel

My Self Adarsh Suryakant Patel. Currently I am working as Assistant Professor at Parul Instiute of Engineering and Technology, MCA Department, Limda, Vadodara. Major Responsibility : * Lectures * Organizing Training and Expert Sessions for * Placement and Recruitment * Faculty Representative