Describe the bug
The MyAppLauncherActivity, which is started by the LauncherActivity, does not seem to return a result when it should. However, if I start an activity from a non-launcher activity, it works as expected. Additionally, when the intent for the CameraActivity is inside the main activity, the CameraActivity does not receive the ActivityResult from the camera.
To Reproduce
Steps to reproduce the behavior:
Launch the application.
The MyAppLauncherActivity is started as the launcherActivity.
In MyAppLauncherActivity, perform an action that should return a result (e.g., starting CameraActivity).
Complete the action in CameraActivity.
Expect MyAppLauncherActivity to receive the result, but it doesn't.
Expected behavior
MyAppLauncherActivity should receive the result from CameraActivity when it is started from the launcherActivity. Additionally, CameraActivity should receive the ActivityResult when its intent is inside the main activity.
Did this ever used to work
No, it has never worked as expected.
Screenshots
N/A
Code Snippets
MyAppLauncherActivity code:
package me.myapp.core.android
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import com.google.androidbrowserhelper.trusted.LauncherActivity
class MyAppLauncherActivity : LauncherActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent?.data?.let { uri ->
if (uri.scheme == "myapp" && uri.host == "capture-invoice") {
val cameraIntent = Intent(this, CameraActivity::class.java).apply {
data = uri
}
startActivityForResult(cameraIntent, CAMERA_ACTIVITY_REQUEST_CODE)
}
}
}
override fun getLaunchingUrl(): Uri {
val uri = this.intent.data
Log.d("MyAppLog", "Using URL from Intent ($uri).")
if (uri != null) {
return uri
}
return Uri.parse("https://web.acc.myapp.dev")
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
Log.d("MyAppLog", "LauncherActivity - onActivityResult: $requestCode, $resultCode, $data")
if (requestCode == CAMERA_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
val redirectIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://web.acc.myapp.dev/received-invoices"))
startActivity(redirectIntent)
}
}
companion object {
private const val CAMERA_ACTIVITY_REQUEST_CODE = 1003
}
}
The last piece of code run in the CameraActivy.kt (tested with logs and debugger)
setResult(RESULT_OK) // Set the result before finishing
Log.d("MyAppLog", "Image sent to server.")
finish()
Describe the bug The MyAppLauncherActivity, which is started by the LauncherActivity, does not seem to return a result when it should. However, if I start an activity from a non-launcher activity, it works as expected. Additionally, when the intent for the CameraActivity is inside the main activity, the CameraActivity does not receive the ActivityResult from the camera.
To Reproduce Steps to reproduce the behavior:
Expected behavior MyAppLauncherActivity should receive the result from CameraActivity when it is started from the launcherActivity. Additionally, CameraActivity should receive the ActivityResult when its intent is inside the main activity.
Did this ever used to work No, it has never worked as expected.
Screenshots N/A
Code Snippets MyAppLauncherActivity code:
The last piece of code run in the CameraActivy.kt (tested with logs and debugger)
Manifest
Smartphone
Additional context