Android Question Simulating Restart Activity

DawningTruth

Active Member
Licensed User
My app needs to redraw certain elements upon a button press.

I have created an algorithm which requires the following steps:

Code: Copy
'Button Pressed
'Do some stuff
'Save Activity Data
'Restart Activity
'Redraw Based on Previous Activity Data

Some of the critical code is in Create and some of it is in Resume. So both need to be executed.

I have tried using:

Code: Copy
Activity_Pause

'Within Pause

Activity_Create

But it does not recreate the activity.

Any suggestions.
 
Use a your own sub like Sub Redraw, instead of trying to restart the activity (call Redraw also in Activity_Create, of course)
Thx LucasMS.

The nature of the views used requires a redraw. I already have the code that does what is required for the screen change orientation.

So in this case I basically need to trigger some sort of configuration change event, which mimics the Activity Lifecycle of a Screen Orientation Change i.e. Pause -> Create -> Resume
 
Upvote 0
Semens approach is elegant.

I've done it before manually by just doing what the app already does when creating the activity. You have to remove all the views, and execute the subs that declare the variables (to reset them).

Code: Copy
Sub Restart
     Activity.RemoveAllViews
     Process_Globals
     Globals
     Activity_Create(True)
     Activity_Resume
End Sub
 
Upvote 0
Semens approach is elegant.

I've done it before manually by just doing what the app already does when creating the activity. You have to remove all the views, and execute the subs that declare the variables (to reset them).

Code: Copy
Sub Restart
     Activity.RemoveAllViews
     Process_Globals
     Globals
     Activity_Create(True)
     Activity_Resume
End Sub
Thx Jake, interesting alternative approach ;-)
 
Upvote 0
Back
Top