[Android] Fix intent result when using StartActivity

Nicolas Pomepuy git at videolan.org
Mon Dec 12 08:04:38 UTC 2022


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

Fix intent result when using StartActivity

Fixes #2776

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

 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 d801caa698..8129b53e25 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() {
 
@@ -203,6 +204,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) {
@@ -243,7 +247,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