[Android] Fix intent result propagation when launched by another app

Nicolas Pomepuy git at videolan.org
Wed Jun 21 08:16:49 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jun  1 09:10:37 2023 +0200| [263247db535a94ae8e7e619361e8a9f3681c4670] | committer: Duncan McNamara

Fix intent result propagation when launched by another app

Fixes #2776

> https://code.videolan.org/videolan/vlc-android/commit/263247db535a94ae8e7e619361e8a9f3681c4670
---

 .../src/org/videolan/vlc/StartActivity.kt          | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
index 768b782964..950bef3b6a 100644
--- a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -39,11 +39,33 @@ import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext
 import org.videolan.libvlc.util.AndroidUtil
 import org.videolan.medialibrary.MLServiceLocator
-import org.videolan.resources.*
+import org.videolan.resources.ACTION_PLAY_FROM_SEARCH
+import org.videolan.resources.ACTION_SEARCH_GMS
+import org.videolan.resources.ACTION_VIEW_ARC
+import org.videolan.resources.AndroidDevices
+import org.videolan.resources.AppContextProvider
+import org.videolan.resources.EXTRA_FIRST_RUN
+import org.videolan.resources.EXTRA_PATH
+import org.videolan.resources.EXTRA_SEARCH_BUNDLE
+import org.videolan.resources.EXTRA_TARGET
+import org.videolan.resources.EXTRA_UPGRADE
+import org.videolan.resources.MOBILE_MAIN_ACTIVITY
+import org.videolan.resources.MOBILE_SEARCH_ACTIVITY
+import org.videolan.resources.PREF_FIRST_RUN
+import org.videolan.resources.TV_MAIN_ACTIVITY
+import org.videolan.resources.TV_ONBOARDING_ACTIVITY
+import org.videolan.resources.TV_SEARCH_ACTIVITY
 import org.videolan.resources.util.getFromMl
 import org.videolan.resources.util.launchForeground
 import org.videolan.resources.util.startMedialibrary
-import org.videolan.tools.*
+import org.videolan.tools.AppScope
+import org.videolan.tools.BETA_WELCOME
+import org.videolan.tools.KEY_CURRENT_SETTINGS_VERSION
+import org.videolan.tools.KEY_TV_ONBOARDING_DONE
+import org.videolan.tools.Settings
+import org.videolan.tools.awaitAppIsForegroung
+import org.videolan.tools.getContextWithLocale
+import org.videolan.tools.putSingle
 import org.videolan.vlc.gui.BetaWelcomeActivity
 import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate.Companion.getStoragePermission
 import org.videolan.vlc.gui.onboarding.ONBOARDING_DONE_KEY
@@ -207,6 +229,7 @@ class StartActivity : FragmentActivity() {
         }
         if (requestCode == PROPAGATE_RESULT) {
             setResult(resultCode, data)
+            finish()
         }
     }
 
@@ -251,6 +274,7 @@ class StartActivity : FragmentActivity() {
         if (Permissions.canReadStorage(applicationContext) || getStoragePermission()) when {
             intent.type?.startsWith("video") == true -> try {
                 startActivityForResult(intent.setClass(this at StartActivity, VideoPlayerActivity::class.java).apply { putExtra(VideoPlayerActivity.FROM_EXTERNAL, true) }, PROPAGATE_RESULT, Util.getFullScreenBundle())
+                return at launch
             } catch (ex: SecurityException) {
                 intent.data?.let { MediaUtils.openMediaNoUi(it) }
             }



More information about the Android mailing list