Android Question Youtube Lib reload the Activity

ronell

Well-Known Member
Licensed User
Longtime User
what are you trying to achieve?
you want to close the app after you press backbutton?

edit: i remove the sample code,
youtube has its own activity , dont know if there is a way to handle the back keypress in youtube activity
 
Last edited:
Upvote 0

hasexxl1988

Active Member
Licensed User
Longtime User
You should expect your Activity to be recreated many times. Use StateManager to preserve the UI state.

Can I disable the update of the Activity completely with the StateManager?


Edit:
If I close the app with the Homebutton of the mobile phone and open it is exactly in the same place as before (there are several panels available, settings etc.). "Activity Resume" is executed.
When going back from the Youtubevideo, "Activity Resume" is also executed, but also reset. I do not understand why.
 
Last edited:
Upvote 0

hasexxl1988

Active Member
Licensed User
Longtime User
I found the mistake.
It is not on the Youtube Lib, but on the adjusted Orientation.
When the video is started:
p.SetScreenOrientation (0)

And when closing the video I have set:
p.SetScreenOrientation (1)

Thus, after changing the Orientation, the Layout is reloaded but this may not happen ...

If I omit the Orientation, the back function of the Youtube Lib works quite normally.

EDIT: /close.

I have solved it as follows:
B4X:
SetActivityAttribute(Main, android:screenOrientation, "portrait")
SetActivityAttribute(Main, android:configChanges, "keyboardHidden|orientation|screenSize")
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…