package com.codesteps.david.startup;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;

import java.io.Console;
import java.util.Random;

import android.widget.Toast;

public class MyService extends Service {
    public MyService() {
    }

    // MyService holds these messages to deliver when requested
    //
    private final String[] m_Messages = {"Hello, World!", "Good Morning!", "Good Evening!", "Good Night to All!"};

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Toast.makeText(this, "onStartCommand - Service Started", Toast.LENGTH_SHORT).show();
        return Service.START_STICKY;
    }

    @Override
    public void onCreate() {
    }

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

    // Return the random message
    //
    public String getMessage() {
        Random rand = new Random();
        return m_Messages[rand.nextInt(4)];
    }
}