startservice not working in Android

android, service

Solution

Once you start the `Service`, it keeps running in the background until you call `stopSelf()`. If you try to start the service again, while it's still running, it won't work. In that case you should use `bindService()`. My advice is to stop the service when you have done your operations.

Problem

I am new in Android. Now i am doing one project using Service class.In my application contains one ListView .When we click on the item in the list view one Service class will be start. But some problems occurring in that place.At the time of first app open the Service class will be work. But if we go back and again press on the ListView the Service class not working. ie, it is not calling that time.Why this problem occurring. Please help me. Code is given below. ``` lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub String item=pat_id[arg2]; CommonClass.item=item; System.out.println("item 1" +CommonClass.item); startService(new Intent(getApplicationContext(),LocationService.class)); //new Async_view_report().execute(rep_url,item,CommonClass.doctor_id); } }); } ```

Original source