2012-03-17 51 views
0

我在小部件,一個ImageView的當過我點擊了它,我開始使用getService如下停止服務手工插件

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

,進而爲MyService類發送消息的MyServiceonCreate到處理器服務與消息

myHandler.sendEmptyMessage(MSG_FETCH_DATA); 

現在我想停止使用ImageView的是服務,所以我怎麼能做到這一點啓動該服務?我的應用程序要求通過小部件手動停止該服務,以便我不使用stopSelf()

+0

追捕,當你想停止這個服務上的ImageView點擊意味着,如果是,那麼請參閱[控件被點擊(http://stackoverflow.com/questions/9671596/how-do-i-start-an-activity-當 - 我的小部件 - 是 - 點擊/ 9671968#9671968)? – 2012-03-17 07:48:04

+0

Intent intent = new Intent(context,MyService.class);這是我在onReceive中如何在單擊ImageView時這樣做的嗎? – Hunt 2012-03-17 09:54:04

回答

1

Android Service doc討論關於停止服務。具體來說,它提到了

context.stopService(Intent service); 

方法。您可以在Android Context doc中閱讀有關此方法的更多信息。

希望這會有所幫助!