Put Android task in foreground
-
wrote on 3 Mar 2018, 21:40 last edited by cristeab 3 Mar 2018, 21:42
Hi
I have an application written mostly in Qt (v.5.9.3) and some code written in Java with an activity and a service. This is a VoIP application and the service is used to manage the SIP stack. I would like to put in foreground the activity that manages the UI when an incoming call is received. Currently I am using the approach below (in Java, the method is called from C++):static void moveActivityToForeground(Context context) { Intent i = new Intent(context, org.qtproject.qt5.MainActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(i); }
however, this works only when there is no other task running in foreground. Other VoIP applications, like CSipSimple or SipDroid are able to bring their UI in front when an incoming call is received even when another task is already in front. I would like to do the same with my application.
thanks
Bogdan -
wrote on 9 Mar 2018, 09:47 last edited by
Hi
I had another method that checked if the task was already in background. This one did not worked correctly. Once I removed this check the above approach works as expected
thanks
Bogdan -
Hi
I have an application written mostly in Qt (v.5.9.3) and some code written in Java with an activity and a service. This is a VoIP application and the service is used to manage the SIP stack. I would like to put in foreground the activity that manages the UI when an incoming call is received. Currently I am using the approach below (in Java, the method is called from C++):static void moveActivityToForeground(Context context) { Intent i = new Intent(context, org.qtproject.qt5.MainActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(i); }
however, this works only when there is no other task running in foreground. Other VoIP applications, like CSipSimple or SipDroid are able to bring their UI in front when an incoming call is received even when another task is already in front. I would like to do the same with my application.
thanks
Bogdanwrote on 4 Mar 2018, 22:45 last edited by@cristeab https://stackoverflow.com/questions/4288889/android-bring-task-to-front
Also this isn't really a Qt question, you would have had better luck on an android forum or even stackoverflow where I found that post.
-
wrote on 5 Mar 2018, 08:17 last edited by
@ambershark said in Put Android task in foreground:
https://stackoverflow.com/questions/4288889/android-bring-task-to-front
Thank you for your reply. I have hoped that someone experienced a similar problem. Java only VoIP application don't seem to have this issue. Also, already tried the above solution, but it does not work
-
@ambershark said in Put Android task in foreground:
https://stackoverflow.com/questions/4288889/android-bring-task-to-front
Thank you for your reply. I have hoped that someone experienced a similar problem. Java only VoIP application don't seem to have this issue. Also, already tried the above solution, but it does not work
wrote on 6 Mar 2018, 00:40 last edited by@cristeab Hmm yea wish I could help more but I haven't experienced it. Hopefully someone else can chime in here. It's more of an android issue rather than a Qt one though so your chances of finding an answer here aren't near as high as elsewhere.
-
@cristeab Hmm yea wish I could help more but I haven't experienced it. Hopefully someone else can chime in here. It's more of an android issue rather than a Qt one though so your chances of finding an answer here aren't near as high as elsewhere.
wrote on 6 Mar 2018, 11:47 last edited byYet, it is very much a Qt question, because Qt programmers work in the context of C++ and Qt and need simple, understandable solutions that interface with the things they work with - Qt code, manifest, just a little piece of Java template code they can adapt without understanding everything it does... This is a rare place where they have any hope of getting answers that offer such solutions.
-
wrote on 9 Mar 2018, 09:47 last edited by
Hi
I had another method that checked if the task was already in background. This one did not worked correctly. Once I removed this check the above approach works as expected
thanks
Bogdan
1/6