Android Question Switch from background to foreground

Sganga61

Member
Licensed User
Longtime User
HI
my question is: simple: when I close my application, it remains active in background so I can receive and view notifications while I use other applications.
What can I do to wake my app from background to foreground state without restarting or reinitializing it?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are two different questions here:
1. How can you "wake" your app?
The answer is that it is usually the user that brings the app to the foreground. You can do it programmatically from a service or receiver but it requires special permission.

2. About restarting the app. The app will not be restarted if it wasn't killed by the OS.
Switch to B4XPages. It simplifies many things.
If you want to continue the app state even after the OS killed the process then you need to save the state with KeyValueStore or any other persistent method.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
1) about to wake the app there is an example to study?
See this in general.

and especially:
Additional changes in Android 10 that are not related to the targetSdkVersion value:

 
Last edited:
Upvote 1

Sganga61

Member
Licensed User
Longtime User
See this in general.

and especially:
Additional changes in Android 10 that are not related to the targetSdkVersion value:

Hi DonManfred
thanks for replay.
I just need a NOTIFICATION when the app is in background
In the first time I follow the example of Erel using NB6 library. In that example there is no auth required.
Mu app works fine on local device (debug or Release) but When I put the file on the Play Store (as not visible test app) they crash anytime on device with Android 14.
You think I can solve with this workaround?
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Hi DonManfred
thanks for replay.
I just need a NOTIFICATION when the app is in background
In the first time I follow the example of Erel using NB6 library. In that example there is no auth required.
Mu app works fine on local device (debug or Release) but When I put the file on the Play Store (as not visible test app) they crash anytime on device with Android 14.
You think I can solve with this workaround?
Did you check this?
https://www.b4x.com/android/forum/threads/notifications-permission-with-targetsdkversion-33.148233/
 
Upvote 0
Top