たぼさんの部屋

いちょぼとのんびり

AppWidget の削除でサービスを停止するためには

Intentを新しく作ってからstopService()

f:id:donsuka_kk:20121218010436p:plain
f:id:donsuka_kk:20121218010441p:plain

stopServiceでonDestroyが呼び出されている。

GPSの印がなくなっている

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
		int[] appWidgetIds) {
	// TODO Auto-generated method stub
	super.onUpdate(context, appWidgetManager, appWidgetIds);
	Log.v(TAG,"onUpdate");
	/*
	 * MServiceを起動する
	 */
	Intent intent = new Intent(context , MService.class);
	intent.setAction(MService.ACTION_INIT);
	context.startService(intent);
	
}

@Override
public void onDisabled(Context context) {
	super.onDisabled(context);
	Log.v(TAG,"onDisabled");
	//MServiceを停止する
	if(MService.isServiceRunning(context, MService.class)){
		Intent intent = new Intent(context , MService.class);	//もう一度Intentを生成する
		context.stopService(intent);
	}
}