[Android] Fix intent result when using StartActivity

Nicolas Pomepuy git at videolan.org
Mon Dec 12 08:05:14 UTC 2022


vlc-android | branch: 3.5.x | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Dec  8 09:04:56 2022 +0100| [fad03ab5feec9a33bc4f32ea43f865eb60aa159c] | committer: Nicolas Pomepuy

Fix intent result when using StartActivity

Fixes #2776


(cherry picked from commit b38f5eea6d45fee5ed8c00f59f6cf42c2cfe4bdb)

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

 application/vlc-android/src/org/videolan/vlc/StartActivity.kt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
index 5ddb6063a0..6a6c3c13da 100644
--- a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -59,6 +59,7 @@ import videolan.org.commontools.TV_CHANNEL_QUERY_VIDEO_ID
 import videolan.org.commontools.TV_CHANNEL_SCHEME
 
 private const val SEND_CRASH_RESULT = 0
+private const val PROPAGATE_RESULT = 1
 private const val TAG = "VLC/StartActivity"
 class StartActivity : FragmentActivity() {
 
@@ -205,6 +206,9 @@ class StartActivity : FragmentActivity() {
         if (requestCode == SEND_CRASH_RESULT) {
             resume()
         }
+        if (requestCode == PROPAGATE_RESULT) {
+            setResult(resultCode, data)
+        }
     }
 
     private fun startApplication(tv: Boolean, firstRun: Boolean, upgrade: Boolean, target: Int, removeDevices:Boolean = false) {
@@ -245,7 +249,7 @@ class StartActivity : FragmentActivity() {
         }
         if (Permissions.canReadStorage(applicationContext) || getStoragePermission()) when {
             intent.type?.startsWith("video") == true -> try {
-                startActivity(intent.setClass(this at StartActivity, VideoPlayerActivity::class.java).apply { putExtra(VideoPlayerActivity.FROM_EXTERNAL, true) })
+                startActivityForResult(intent.setClass(this at StartActivity, VideoPlayerActivity::class.java).apply { putExtra(VideoPlayerActivity.FROM_EXTERNAL, true) }, PROPAGATE_RESULT)
             } catch (ex: SecurityException) {
                 intent.data?.let { MediaUtils.openMediaNoUi(it) }
             }



More information about the Android mailing list