alirezahassan Active Member Licensed User Longtime User Nov 6, 2021 #1 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: Copy 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?
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: Copy 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 alirezahassan Nov 6, 2021 With this code, you can open your activity if it is in pause mode without starting. (Activity_Resume) B4X: Copy Dim Intent As Intent Intent.Initialize("", "") Intent.SetComponent(Application.Packagename&"/.youractivity") ' lowercase Intent.Flags = 0x00020000 ' or 0x04000000 StartActivity(Intent) thanks Mr. Amirhossein Aghajari
With this code, you can open your activity if it is in pause mode without starting. (Activity_Resume) B4X: Copy 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 Nov 6, 2021 #2 alirezahassan said: I want to write code that opens the application in Activity_Resume (not Activity_Create) Click to expand... 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 said: I want to write code that opens the application in Activity_Resume (not Activity_Create) Click to expand... 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?
alirezahassan Active Member Licensed User Longtime User Nov 6, 2021 #3 agraham said: 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? Click to expand... 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: Nov 6, 2021 Upvote 0
agraham said: 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? Click to expand... 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.
agraham Expert Licensed User Longtime User Nov 6, 2021 #4 alirezahassan said: I want to open the app in Resident App. Click to expand... I've no idea what this means. Upvote 0
alirezahassan said: I want to open the app in Resident App. Click to expand... I've no idea what this means.
alirezahassan Active Member Licensed User Longtime User Nov 6, 2021 #5 agraham said: I've no idea what this means. Click to expand... Recent App I wrote it wrong. Was corrected Upvote 0
agraham said: I've no idea what this means. Click to expand... Recent App I wrote it wrong. Was corrected
agraham Expert Licensed User Longtime User Nov 6, 2021 #6 Sorry, I still don't understand what you mean. Upvote 0
M Mahares Expert Licensed User Longtime User Nov 6, 2021 #7 alirezahassan said: Because there is some information inside the activity that will be deleted if it is run again. what should i do? Click to expand... 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 said: Because there is some information inside the activity that will be deleted if it is run again. what should i do? Click to expand... 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.
alirezahassan Active Member Licensed User Longtime User Nov 6, 2021 #8 With this code, you can open your activity if it is in pause mode without starting. (Activity_Resume) B4X: Copy 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
With this code, you can open your activity if it is in pause mode without starting. (Activity_Resume) B4X: Copy Dim Intent As Intent Intent.Initialize("", "") Intent.SetComponent(Application.Packagename&"/.youractivity") ' lowercase Intent.Flags = 0x00020000 ' or 0x04000000 StartActivity(Intent) thanks Mr. Amirhossein Aghajari