Android Question help needed: keep msgbox on screen when activity resumes

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
i need help...

when my app is being pushed to the background for example due to incomming call or sms, and then i load it back either from desktop icon or task manager,
any msgbox that was active on screen is gone
is there a way to make sure it will be returned complely to the same view as it was before the interruption?
if there was a msgbox on screen so the msgbox will still be on screen

thanks
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
You might have to save your app's UI state in onPause & restore it in onResume.

- Colin.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
thanks
how do i do it?
how do i store the entire current state and then return to it?
savig the active form and text in msgbox is not really doable i think
Search the forum for KVS. Basically you use key/value pairs to save the relevant state of each view so that it can be restored later. It seems complicated at first, but when you look into it a bit deeper it's very straightforward. For a dialog, all you'd need to do is save the title, message & button configurations when the activity pauses, then fetch those back & use them to rebuild & display the dialog when the activity resumes.

- Colin.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Thank you Colin
It seems that this will force me to a lot of modifications. the app huge so it is a big pain.
I need either block any other thing from breaking my app (doesn't seem to be logic) or a magic solution so on resume it will be really resumed without loosing anything as happens now

I will however read what you suggested...

Thanks
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Thank you Colin
It seems that this will force me to a lot of modifications. the app huge so it is a big pain.
I need either block any other thing from breaking my app (doesn't seem to be logic) or a magic solution so on resume it will be really resumed without loosing anything as happens now

I will however read what you suggested...

Thanks
You may not need to do that many code changes...
Create a module/class to call when the Pause event takes place, then go through all the Active Activity child views and child's child views and "save" the needed info, if important.
Then in the Resume event read back and re-set the activity state to its "original" state...
This will behave as a "snapshot" of the active activity, if you will
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
well pals, this is not really doable at least not in my case
the app is huge, lots of data on on mostly dynamic so i think this is a nice idea but not suitable
in any case - is this a system bug?
why on resume part of the functionality as message box displayed on screen is gone?
that does not make any sense at leat to me...

as i need a solution for this
is there a way to prevent this "odd" behaviour?

thought on alternative:
can any one help on how to create a dynamic/programatically created form/panel that will have a label and 2 buttons to act as the msgbox and replace it?
this may be working as form / panels are not lost on resume
best will be that the form will not cover the entire screen and leave the form bellow shown
i hope i made my idea clear

thanks
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
There are a few dialog replacement libs in the forum... chose one and give it a try!
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
i need help...

when my app is being pushed to the background for example due to incomming call or sms, and then i load it back either from desktop icon or task manager,
any msgbox that was active on screen is gone
is there a way to make sure it will be returned complely to the same view as it was before the interruption?
if there was a msgbox on screen so the msgbox will still be on screen

thanks
Late to this thread...
Why use the built-in messagebox at all?
If you use a panel of your own, it will still be there when the app resumes.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Late to this thread...
Why use the built-in messagebox at all?
If you use a panel of your own, it will still be there when the app resumes.
Not necessarily. If the Panel (or whatever view he uses) is not visible by default & the OS kills the app while it's in the background, then the app (& the UI) will be resumed in its default start-up state - meaning the Panel won't be visible.

- Colin.
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Not necessarily. If the Panel (or whatever view he uses) is not visible by default & the OS kills the app while it's in the background, then the app (& the UI) will be resumed in its default start-up state - meaning the Panel won't be visible.

- Colin.
True. No clever way around that , I can think of, without saving and restoring the state.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
in any case - is this a system bug?
No, this is how Android works. It's up to the app to remember its state, not Android's (Android's rules, not mine/not yours).
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Late to this thread...
Why use the built-in messagebox at all?
If you use a panel of your own, it will still be there when the app resumes.
Indeed, that was the idea I came up with

But why are msgboxes get lost? Is this a bug?

Any idea how to create such floating panel?
That will not cover the entire screen and be on top of the previous panel yet showing it?
And to create it on the fly programmatically?

Thanks
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
But why are msgboxes get lost? Is this a bug?
No, this is how Android works with the native dialog class

Any idea how to create such floating panel?
That will not cover the entire screen and be on top of the previous panel yet showing it?
And to create it on the fly programmatically?
Check out B4XDialog, part of XUI Views library (an internal library)
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Here is an example.

Yes, B4xDialog will do all of this and more... but I had already written this before the @OliverA 's post appeared.

EDIT: This is a very simple example to show the technique.
 

Attachments

  • SIMPLEOVERLAY.zip
    15.5 KB · Views: 51
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Here is an example.

Yes, B4xDialog will do all of this and more... but I had already written this before the @OliverA 's post appeared.

EDIT: This is a very simple example to show the technique.
No as it is based on a secondary view and that breaks the flow
Look at the sample I've uploaded and the explanation it will all be clear as per what I need

Thanks
 
Upvote 0
Top