I need to repeat Toast after every 10 second. How can I do this thing.
Below I add a simple code of the Service Class :
public class MyService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
Toast.makeText(this, "Repeat After 10 Sec", Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
Toast.makeText(this, "Service Stopped", Toast.LENGTH_LONG).show();
}
@Override
public void onStart(Intent intent, int startid) {
Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
}
Today I have done this using CountDownTimer and Service
here is sample code.
In service
countdowntimer class