package com.xixun.xixunplayer;

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

public class MainService extends Service {

    static MainService ins;
    @Override
    public void onCreate() {
        super.onCreate();
        ins = this;
        Util.println("==>> MainService onCreate >>>> "+hashCode()+" Thread: "+Thread.currentThread().getId());
        UDPThread.startSocket();
        TCPThread.startServer(3333);
        if(MainActivity.ins==null) {
            var intent = new Intent(this, MainActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        Util.println("==<< MainService onDestroy <<<< this "+hashCode());
        ins = null;
        System.gc();
    }

    @Override
    public IBinder onBind(Intent intent) {
        throw new UnsupportedOperationException("Not yet implemented");
    }
}