Android Question Restart Entire app? & get navbar heigh and status bar height

alexwekell

Member
Licensed User
Longtime User
I've added the ability to toggle translucent bars on and off for 4.4+ users, but the effects only take place once the app is reloaded. My non-elegant solution would be to inform the user that changes won't take effect until the app is restarted, but I'd like to have a msgbox that could do it for them. I want to close and then reopen the app (as if the user pressed back to leave the app or force closed the app), is this possible?

Also to add the toggle for translucent bars I need to calculate the dip size of the status bar and navbar, right now I have it hard coded. Is there anyway to calculate these two values? And I also need the ability to detect if the user has software or hardware keys, is that possible?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use a service for that. Call Activity.Finish followed by StartService. The service will then call StartActivity to start the activity again.

A better solution is to create a "reset state" sub that is called when the activity is created and resets the state and loads the layout.

You can compare the 100%y to GetDisplayeLayoutValues.Height.

Please start a new thread for the last question.
 
Upvote 0

alexwekell

Member
Licensed User
Longtime User

Activity finish only includes my current activity though. I have a settings menu and when the toggle for the translucent bars is called and is runs activity finish it only resets my settings screen. I need to restart every single activity in my app.
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
How'd you toggle the bars?

You can compare the 100%y to GetDisplayLayoutValues.Height.

How do you do it if you have a transparent action bar too? (both top and bottom bars)

EDIT: The answer to that is, (Activity.Height -GetDeviceLayoutValues.Height) * 0.5
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…