Android/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/RestartService.java
2024-08-22 17:37:46 +08:00

34 lines
886 B
Java

package com.xixun.xixunplayer;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
public class RestartService extends Service {
static RestartService ins;
@Override
public void onCreate() {
super.onCreate();
ins = this;
Util.println("==>> RestartService onCreate >>>> "+hashCode());
if(MainActivity.ins!=null) return;
var intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
@Override
public void onDestroy() {
super.onDestroy();
Util.println("==<< RestartService onDestroy <<<< this "+hashCode());
ins = null;
System.gc();
}
@Override
public IBinder onBind(Intent intent) {
throw new UnsupportedOperationException("Not yet implemented");
}
}