Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Put Android task in foreground
QtWS25 Last Chance

Put Android task in foreground

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 3 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cristeab
    wrote on 3 Mar 2018, 21:40 last edited by cristeab 3 Mar 2018, 21:42
    #1

    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

    A 1 Reply Last reply 4 Mar 2018, 22:45
    0
    • C Offline
      C Offline
      cristeab
      wrote on 9 Mar 2018, 09:47 last edited by
      #6

      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 Reply Last reply
      0
      • C cristeab
        3 Mar 2018, 21:40

        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

        A Offline
        A Offline
        ambershark
        wrote on 4 Mar 2018, 22:45 last edited by
        #2

        @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.

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        1 Reply Last reply
        1
        • C Offline
          C Offline
          cristeab
          wrote on 5 Mar 2018, 08:17 last edited by
          #3

          @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

          A 1 Reply Last reply 6 Mar 2018, 00:40
          0
          • C cristeab
            5 Mar 2018, 08:17

            @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

            A Offline
            A Offline
            ambershark
            wrote on 6 Mar 2018, 00:40 last edited by
            #4

            @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.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            M 1 Reply Last reply 6 Mar 2018, 11:47
            0
            • A ambershark
              6 Mar 2018, 00:40

              @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.

              M Offline
              M Offline
              mvuori
              wrote on 6 Mar 2018, 11:47 last edited by
              #5

              Yet, 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.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                cristeab
                wrote on 9 Mar 2018, 09:47 last edited by
                #6

                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 Reply Last reply
                0

                1/6

                3 Mar 2018, 21:40

                • Login

                • Login or register to search.
                1 out of 6
                • First post
                  1/6
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved