I want to create a service in my application that creates a notification every 3 seconds. I create this code, but it only works once when I launch my application. I want to be notified every 3 seconds! even when I close my application, I get notifications! (because of this I create a service) please help me.
public class notifService extends Service { ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); private static final int HELLO_ID = 1; @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); final Intent intent1 = new Intent(this, notifService.class); scheduler.schedule(new Runnable() { @Override public void run() {
java android notifications
Fcoder
source share