diff --git a/XixunPlayer/app/src/main/AndroidManifest.xml b/XixunPlayer/app/src/main/AndroidManifest.xml index 43fd492..de22683 100644 --- a/XixunPlayer/app/src/main/AndroidManifest.xml +++ b/XixunPlayer/app/src/main/AndroidManifest.xml @@ -1,10 +1,12 @@ + xmlns:tools="http://schemas.android.com/tools" > - + @@ -16,27 +18,40 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/Theme.XixunPlayer"> + android:theme="@style/Theme.XixunPlayer" > + + + + + + + android:label="@string/app_name" > - + + - + - - + + + + \ No newline at end of file diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/BootCompletedReceiver.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/BootCompletedReceiver.java index 88aa557..6b72b26 100644 --- a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/BootCompletedReceiver.java +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/BootCompletedReceiver.java @@ -8,6 +8,7 @@ public class BootCompletedReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { System.out.println("BootCompletedReceiver onReceive ---- "+intent.getAction()); + if(MainActivity.ins!=null) return; intent = new Intent(context, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/MainActivity.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/MainActivity.java index 78569c8..900d714 100644 --- a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/MainActivity.java +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/MainActivity.java @@ -59,6 +59,8 @@ public class MainActivity extends ComponentActivity implements Choreographer.Fra @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + startService(new Intent(this, RestartService.class)); + System.out.println("---- MainActivity onCreate ---- UI Thread: "+Thread.currentThread().getId()); ins = this; if(ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) init(); diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/RestartService.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/RestartService.java new file mode 100644 index 0000000..59098fa --- /dev/null +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/RestartService.java @@ -0,0 +1,23 @@ +package com.xixun.xixunplayer; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; + +public class RestartService extends Service { + + @Override + public void onCreate() { + super.onCreate(); + System.out.println("---- RestartService onCreate"); + if(MainActivity.ins!=null) return; + var intent = new Intent(this, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + + @Override + public IBinder onBind(Intent intent) { + throw new UnsupportedOperationException("Not yet implemented"); + } +} \ No newline at end of file