Android Question #SupportedOrientations: portrait and camera intent resets/reload activity?

Daica

Active Member
Licensed User
Hi everyone,
I am coming across this weird issue and I'm not sure how to work around it.

I am displaying markers on a Google map and when the orientation change, the map is reset. To "fix" this issue, I have set the orientation to portrait only like so:
#SupportedOrientations: portrait

This works fine, however, if I open the camera using the camera intent code found here: Intent Based Camera | B4X Programming Forum

When the camera is opened and then a picture is taken, if the phone is in landscape once the app resumes, the map is re-drawn.
I have no idea how to stop the map from being re-drawn using the camera intent. Does anyone have this problem before?

EDIT:
I have uploaded an example to show what I mean.

1. Add your Google Map API key into the manifest editor
2. Run the app
3. Tap on the map to add a marker
4. Tap on the marker to open the system camera using Camera Intent
5. Take a picture in landscape mode then press OK to go back to the app while still in landscape or just press the back button while in landscape mode

You will see that the map is refreshed and all the markers are gone now even though in our app, we set
#SupportedOrientations: portrait
 

Attachments

  • Google Map with Camera Intent.zip
    10.4 KB · Views: 244
Last edited:

Daica

Active Member
Licensed User
Can you post the filtered logs?

How do I do that? Sorry still new to this.
Also, this is kind of weird, but using the same example project I posted on a different phone, it's not happening on the different phone.
Galaxy S9 -> does not reset
Galaxy S10 -> Resets

EDIT:

Here is the log from the Galaxy S10, where the map resets if the phone is in landscape mode after coming back from camera intent:
1615744319160.png


And here is the log from the Galaxy S9, where the map does not reset in landscape mode after coming back from camera intent
1615744431349.png


It seems like on the S10. the activity is being re-created where as on the S9, it is not. Although I now know the problem, I'm not sure of a solution other than using the manifest to stop the "main" activity from being destroyed
 
Last edited:
Upvote 0

Daica

Active Member
Licensed User
Right click to copy the text.

The issue is not related to the orientation change. It is related to the app being killed while it is in the background.

You can add a service and call Service.StartForeground before sending the camera intent.

Hi Erel,
The app does not reset if the phone is kept in portrait mode, but it does reset when the phone is physically in landscape mode.
I also tried what you mentioned about the service, the app still resets if the phone is landscape.
So far, the only thing that work is by adding this into the manifest:
SetActivityAttribute(Main, android:configChanges, "orientation|screenSize")
 
Upvote 0
Top