like this,but can't find answer:
Bringing my app to the front | B4X Programming Forum
Hi all. I have a service that is running and what I want to do is at a certain time bring my paused activity to the front. How do I do this? Thanks.
Android provides a simple way to switch an application from the background to the foreground by sending an Intent and starting an Activity. We can use the following code to achieve this function:
Intent intent = new Intent(context, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
In the above code, MainActivity is the class name of the Activity we want to start, and context is the current context.
This code will create a new task stack and add MainActivity to the task stack. It will then display the task stack to the foreground and display the MainActivity.
Method 2: Use ActivityManager
Another way is to use the ActivityManager class to switch the application to the foreground. This method is relatively complex, but allows for more fine-grained control. Here is sample code:
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> processes = am.getRunningAppProcesses();
for (ActivityManager.RunningAppProcessInfo process : processes) {
if (process.processName.equals(context.getPackageName())) {
am.moveTaskToFront(process.pid, 0);
break;
}