I am developping an application that uses a remote Service that we bought to manage the navigation of our trucks. So we bind to the service and we send him several commands as launch navigation etc, and the service answers threw a ServiceConnection. (TRemoteServiceConnection). I Have a procedure OnHandleMessage in which I receive the result of the commands from the service. On a result of the service, The service is in the foreground and I Would like to put my application to the foreground. So I was thinking about using an intent this way but nothing happens:
Intent := TJIntent.Create;
Intent.setClassName(StringToJString('com.embarcadero.And_PTV'), StringToJString('com.embarcadero.firemonkey.FMXNativeActivity'));
Intent.setAction(TJIntent.JavaClass.ACTION_MAIN);
Intent.addCategory(TJIntent.JavaClass.CATEGORY_LAUNCHER);
Intent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_REORDER_TO_FRONT);
SharedActivityContext.startActivity(Intent);
I also tried other flags as "FLAG_ACTIVITY_REORDER_TO_FRONT" or "FLAG_ACTIVITY_CLEAR_TOP" or "FLAG_ACTIVITY_BROUGHT_TO_FRONT" but it still doesn't work. However with the flag "FLAG_ACTIVITY_NEW_TASK" my app launches but its a new instance of the activity that starts and I don't want it.