I use this code for installing APK: https:// stackoverflow. com/a/61889386/14152249 (sorry for whitespaces, can't post links here for a while)
My activity launch mode is set to
SingleTop. I call
OnActivityResult (I need to uninstall app before that and I check if it's uninstalled there). Also I modified that code to pass the
PendingIntentFlags.UpdateCurrent flag during the creation of
PendingIntent object. The problem is when APK is successfully installed or when installer is waiting for user action,
OnNewIntent is always properly called and then I do some stuff. But when user aborts install,
OnNewIntent is not called (occasionally though it DOES get called). I couldn't find anything about such a behavior. How can I fix this? Or maybe it has something to do with the device which I'm debugging on (Xiaomi Mi 9T Pro with MIUI 12 based on Android 10)?
I need to show an alert dialog when app failed to install and stop the process. As a workaround I use
StartActivityForResult and then in
OnActivityResult I wait for 5 seconds and check if app is installed. But this workaround is bad of course because if installation takes more than 5 seconds then alert dialog will be shown anyway though the app itself will be installed.
Also I wrote a simple app with the same functionality in Java and as far as I can see there it works as intended. Could it be a Xamarin bug?