Android Question open app from Recent app

alirezahassan

Active Member
Licensed User
hi all,
I have a sensitive activity.
I want to write a service that, after 10 seconds when the user was out of the app, opens an activity from the Recent app. The problem is that I do not want the activity to start again, which means:
B4X:
StartActivity(My_Activity) ' i don't want
I want to write code that opens the application in Activity_Resume (not Activity_Create)
Because there is some information inside the activity that will be deleted if it is run again.
what should i do?
 
Solution
With this code, you can open your activity if it is in pause mode without starting. (Activity_Resume)
B4X:
Dim Intent As Intent
Intent.Initialize("", "")
Intent.SetComponent(Application.Packagename&"/.youractivity") ' lowercase
Intent.Flags = 0x00020000  ' or 0x04000000
StartActivity(Intent)
thanks Mr. Amirhossein Aghajari

agraham

Expert
Licensed User
Longtime User
I want to write code that opens the application in Activity_Resume (not Activity_Create)
You can't choose. Android decides if it can bring an existing activity forward with Activity_Resume or whether it needs to recreate it. Why can't you use the FirstTime parameter of Activity_Create?
 
Upvote 0

alirezahassan

Active Member
Licensed User
You can't choose. Android decides if it can bring an existing activity forward with Activity_Resume or whether it needs to recreate it. Why can't you use the FirstTime parameter of Activity_Create?
The application is open. But paused
I want to open the app in Recent App.
Because I have parameters in the activity that will be cleared if it starts again.
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Because there is some information inside the activity that will be deleted if it is run again.
what should i do?
Ali: I was taught that if you are worried about loosing data when the app is paused or killed, is to store the data in a map file, or list file, or text file, or SQLite database or KVS whatever applies. Then retrieve the data when the activity resumes or restarts. Can any of those stores be applied to your app.
 
Upvote 0

alirezahassan

Active Member
Licensed User
With this code, you can open your activity if it is in pause mode without starting. (Activity_Resume)
B4X:
Dim Intent As Intent
Intent.Initialize("", "")
Intent.SetComponent(Application.Packagename&"/.youractivity") ' lowercase
Intent.Flags = 0x00020000  ' or 0x04000000
StartActivity(Intent)
thanks Mr. Amirhossein Aghajari
 
Upvote 0
Solution
Top