Service Using IntentService on Android

public class MyService extends IntentService {

    int counter = 0;

    public MyService() {
        super("MyServiceThread");
    }

    @Override
    protected void onHandleIntent(@Nullable Intent intent) {

        counter++;
        Handler handler = new Handler(getMainLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(MyService.this, "Service Stared: " + counter, Toast.LENGTH_SHORT).show();
            }
        });

        for (int i = 0; i < 10; i++) {
            try {
                wait(1500);

            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }

    @Override
    public void onDestroy() {
        Toast.makeText(MyService.this, "Service Stopped", Toast.LENGTH_SHORT).show();
    }
}

References
https://www.youtube.com/watch?v=cpq163QF2nM
https://github.com/mhdr/AndroidSamples/tree/master/100