package net.ddns.mahaljsp.clockwidget;

import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
import android.support.annotation.Nullable;

/**
 * Created by Thomas Wu(mahaljsp@gmail.com) on 2016/12/24.
 */

public class ClockService extends Service {
    TimeTickReceiver timeTickReceiver;
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
    @Override
    public void onCreate() {
        if(timeTickReceiver==null)timeTickReceiver=new TimeTickReceiver();
    }
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        registerReceiver(timeTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
        return Service.START_STICKY;
    }
    @Override
    public void onDestroy() {
        unregisterReceiver(timeTickReceiver);
    }
}
