@@ -306,37 +306,7 @@ class MainActivity : AppCompatActivity() {
306
306
}
307
307
})
308
308
309
- val exePath = intent.getStringExtra(" exePath" )
310
-
311
- if (exePath != null ) {
312
- val intent = Intent (this , EmulationActivity ::class .java).apply {
313
- flags = Intent .FLAG_ACTIVITY_REORDER_TO_FRONT
314
- }
315
-
316
- sendBroadcast(
317
- Intent (ACTION_RUN_WINE ).apply {
318
- putExtra(" exePath" , exePath)
319
- }
320
- )
321
-
322
- startActivityIfNeeded(intent, 0 )
323
- }
324
-
325
- intent?.data?.let { uri ->
326
- val filePath = FilePathResolver .resolvePath(this , uri)
327
-
328
- val runWineIntent = Intent (ACTION_RUN_WINE ).apply {
329
- putExtra(" exePath" , filePath)
330
- }
331
-
332
- sendBroadcast(runWineIntent)
333
-
334
- val emulationActivityIntent = Intent (this @MainActivity, EmulationActivity ::class .java).apply {
335
- flags = Intent .FLAG_ACTIVITY_REORDER_TO_FRONT
336
- }
337
-
338
- startActivityIfNeeded(emulationActivityIntent, 0 )
339
- }
309
+ onNewIntent(intent)
340
310
}
341
311
342
312
override fun onPostCreate (savedInstanceState : Bundle ? ) {
@@ -768,6 +738,44 @@ class MainActivity : AppCompatActivity() {
768
738
}
769
739
}
770
740
741
+ override fun onNewIntent (intent : Intent ) {
742
+ val exePath = intent.getStringExtra(" exePath" )
743
+
744
+ val emulationActivityIntent = Intent (this , EmulationActivity ::class .java).apply {
745
+ flags = Intent .FLAG_ACTIVITY_REORDER_TO_FRONT
746
+ }
747
+
748
+ if (exePath != null ) {
749
+ if (File (exePath).exists()) {
750
+ sendBroadcast(
751
+ Intent (ACTION_RUN_WINE ).apply {
752
+ putExtra(" exePath" , exePath)
753
+ }
754
+ )
755
+
756
+ startActivityIfNeeded(emulationActivityIntent, 0 )
757
+ }
758
+ }
759
+
760
+ intent.data?.let { uri ->
761
+ val filePath = FilePathResolver .resolvePath(this , uri)
762
+
763
+ if (filePath != null ) {
764
+ if (File (filePath).exists()) {
765
+ sendBroadcast(
766
+ Intent (ACTION_RUN_WINE ).apply {
767
+ putExtra(" exePath" , filePath)
768
+ }
769
+ )
770
+ }
771
+ }
772
+
773
+ startActivityIfNeeded(emulationActivityIntent, 0 )
774
+ }
775
+
776
+ super .onNewIntent(intent)
777
+ }
778
+
771
779
companion object {
772
780
@SuppressLint(" SdCardPath" )
773
781
val appRootDir = File (" /data/data/com.micewine.emu/files" )
0 commit comments