Hello Forum.
How can I stop my widget / service if I take it from the home screen.
If I repeat it, then it is started twice.
But I do not get it stopped.
I want its start new, when I put it on the home screen.
Here the code.
[HIGH]
public class AppWidget extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
Intent intent = new Intent(context, UpdateServiceForAppWidgetProvider.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
intent.setAction("de.mk.android_motionwidget.SECONDS_UPDATE");
context.startService(intent);
}
}
[/HIGH]
And the Service
[HIGH]
public class UpdateServiceForAppWidgetProvider extends Service {
@Override
public void onStart(Intent intent, int startId) {
// <<<< What here is stopp please. But how?
}
super.onStart(intent, startId);
}
}
[/HIGH]
So please. How can i stop this service for my widget. If I take it from my screen.
How can I stop my widget / service if I take it from the home screen.
If I repeat it, then it is started twice.
But I do not get it stopped.
I want its start new, when I put it on the home screen.
Here the code.
[HIGH]
public class AppWidget extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
Intent intent = new Intent(context, UpdateServiceForAppWidgetProvider.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
intent.setAction("de.mk.android_motionwidget.SECONDS_UPDATE");
context.startService(intent);
}
}
[/HIGH]
And the Service
[HIGH]
public class UpdateServiceForAppWidgetProvider extends Service {
@Override
public void onStart(Intent intent, int startId) {
// <<<< What here is stopp please. But how?
}
super.onStart(intent, startId);
}
}
[/HIGH]
So please. How can i stop this service for my widget. If I take it from my screen.