Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Services in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 151
    Comment on it

    Services in Android is a component that runs in the background without any user interaction or interface.


    Services in android are used to interact with the hardware and software for providing interactions and accomplishing tasks.


    Services are of two types:

    Started : A Service is started when a application component such as an activity invokes it by calling startService(). Once started, a service can run in the background indefinitely, even if the component that started it is destroyed


    Bound : A service is "bound" when an application component binds to it by calling bindService(). A bound service offers a client-server interface that allows components to interact with the service, send requests, get results, and even do so across processes with inter-process communication.


      // Start the service
     public void startService(View view) {
      startService(new Intent(this, MyService.class));
     }
    
      // Stop the service
     public void stopService(View view) {
      stopService(new Intent(this, MyService.class));
     }
    
      @Override
     public boolean onCreateOptionsMenu(Menu menu) {
    
       getMenuInflater().inflate(R.menu.activitymain, menu);
      return true;
     }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: