0

I have a ImageView in Widget , when ever i click over it i start a service using getService as follows

Intent intent = new Intent(context,MyService.class);    
PendingIntent pendingServiceIntent = PendingIntent.getService(context,0 , 
            intent , 0);

and in turn MyService class send a message to handler in onCreate of MyService to start the service with a message

  myHandler.sendEmptyMessage(MSG_FETCH_DATA);

Now i want to stop that service using that ImageView , so how can i do that ? My application demands to stop this service manually by widget so that i am not using stopSelf()

Hunt
  • 8,215
  • 28
  • 116
  • 256
  • hunt,when you want to stop this Service means on ImageView Click if yes then see [Widget is clicked](http://stackoverflow.com/questions/9671596/how-do-i-start-an-activity-when-my-widget-is-clicked/9671968#9671968)? – ρяσѕρєя K Mar 17 '12 at 07:48
  • Intent intent = new Intent(context,MyService.class); this is how i did it in a onReceive when a ImageView is clicked is this the way right ? – Hunt Mar 17 '12 at 09:54

1 Answers1

1

The Android Service doc talks about stopping a service. Specifically, it mentions the

context.stopService(Intent service);

method. You can read more about this method in the Android Context doc.

Hope this helps!

mfsiega
  • 2,852
  • 19
  • 22