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. Run QT application on boot using Android boot complete intent
Forum Updated to NodeBB v4.3 + New Features

Run QT application on boot using Android boot complete intent

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
10 Posts 5 Posters 1.6k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    mkre
    wrote on 8 Oct 2019, 18:31 last edited by
    #1

    Hello,
    I'm trying to launch my QT application on an Android device on boot. Unfortunately, I don't know what to call in the 'onReceive' method. Any Ideas?

    In the manifest, I've allowed the boot complete permission and I've attached the receiver to the intent:

        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    ...
    ...
    ...
        <receiver android:name="org.qtproject.example.boot.BootReceiver" android:enabled="true">
            <intent-filter android:priority="100">
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>
    

    Here is the boot receiver:

    public class BootReceiver extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
               what goes here??
        }
    
    }
    
    K 1 Reply Last reply 6 Mar 2020, 08:43
    0
    • N Offline
      N Offline
      namduc
      wrote on 6 Mar 2020, 07:25 last edited by
      #2

      I am in need of something like that, who can help I?
      Thanks for all!

      1 Reply Last reply
      0
      • M mkre
        8 Oct 2019, 18:31

        Hello,
        I'm trying to launch my QT application on an Android device on boot. Unfortunately, I don't know what to call in the 'onReceive' method. Any Ideas?

        In the manifest, I've allowed the boot complete permission and I've attached the receiver to the intent:

            <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
        ...
        ...
        ...
            <receiver android:name="org.qtproject.example.boot.BootReceiver" android:enabled="true">
                <intent-filter android:priority="100">
                    <action android:name="android.intent.action.BOOT_COMPLETED"/>
                </intent-filter>
            </receiver>
        

        Here is the boot receiver:

        public class BootReceiver extends BroadcastReceiver {
        
            @Override
            public void onReceive(Context context, Intent intent) {
                   what goes here??
            }
        
        }
        
        K Offline
        K Offline
        KroMignon
        wrote on 6 Mar 2020, 08:43 last edited by
        #3

        @mkre I guess you should do this:

        public class BootReceiver extends BroadcastReceiver {
            @Override
            public void onReceive(Context context, Intent intent) {
                // StartActivity is the class name of your activity
                // => cf android:name attribute from  activity tag in AndroidManifest.xml
                Intent i = new Intent(context, StartActivity.class);  
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(i); 
            }
        }
        

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        1 Reply Last reply
        3
        • N Offline
          N Offline
          namduc
          wrote on 6 Mar 2020, 10:15 last edited by
          #4

          Great, it worked for me
          On the sidelines, I need my application to run continuously on android devices so is there a way to block the Home button and Menu button so that the app does not exit when the user presses them.
          Any ideas or links to help me would be so grateful!
          Thank you very much!

          J 1 Reply Last reply 6 Mar 2020, 11:53
          0
          • N namduc
            6 Mar 2020, 10:15

            Great, it worked for me
            On the sidelines, I need my application to run continuously on android devices so is there a way to block the Home button and Menu button so that the app does not exit when the user presses them.
            Any ideas or links to help me would be so grateful!
            Thank you very much!

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 6 Mar 2020, 11:53 last edited by
            #5

            @namduc said in Run QT application on boot using Android boot complete intent:

            is there a way to block the Home button and Menu button so that the app does not exit when the user presses them.

            I don't think so and who would like to use such an app? Use a background service if you want to do something if the main app is not running.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            N 1 Reply Last reply 10 Mar 2020, 02:36
            0
            • M Offline
              M Offline
              MajidKamali
              wrote on 7 Mar 2020, 00:19 last edited by
              #6

              Can't a regular Qt Qml app be shown in android on top of other apps?
              using WindowManager.LayoutParams.TYPE_SYSTEM_ALERT in QtActivity, somewhere.

              1 Reply Last reply
              0
              • J jsulm
                6 Mar 2020, 11:53

                @namduc said in Run QT application on boot using Android boot complete intent:

                is there a way to block the Home button and Menu button so that the app does not exit when the user presses them.

                I don't think so and who would like to use such an app? Use a background service if you want to do something if the main app is not running.

                N Offline
                N Offline
                namduc
                wrote on 10 Mar 2020, 02:36 last edited by
                #7

                @jsulm i'm building a app for Working Kiosk Mode in Android,Of course I will have the function to exit my application when needed.
                can you help me?
                Thanks!

                J 1 Reply Last reply 10 Mar 2020, 05:31
                0
                • N namduc
                  10 Mar 2020, 02:36

                  @jsulm i'm building a app for Working Kiosk Mode in Android,Of course I will have the function to exit my application when needed.
                  can you help me?
                  Thanks!

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 10 Mar 2020, 05:31 last edited by
                  #8

                  @namduc As far as I know there is kiosk mode in Android since Lollipop. You should take a look at that.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  N 1 Reply Last reply 10 Mar 2020, 07:46
                  0
                  • J jsulm
                    10 Mar 2020, 05:31

                    @namduc As far as I know there is kiosk mode in Android since Lollipop. You should take a look at that.

                    N Offline
                    N Offline
                    namduc
                    wrote on 10 Mar 2020, 07:46 last edited by namduc 3 Oct 2020, 07:47
                    #9

                    @jsulm yes, i I followed this tutorial but when pressing the Home button the app still exits, this tutorial is written in java, I don't know where the error was, are there any instructions related to Qt?
                    https://www.andreasschrade.com/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/

                    J 1 Reply Last reply 10 Mar 2020, 08:18
                    0
                    • N namduc
                      10 Mar 2020, 07:46

                      @jsulm yes, i I followed this tutorial but when pressing the Home button the app still exits, this tutorial is written in java, I don't know where the error was, are there any instructions related to Qt?
                      https://www.andreasschrade.com/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 10 Mar 2020, 08:18 last edited by
                      #10

                      @namduc What I meant was that there should be already kiosk mode in Android in recent versions, so no need to implement it. My guess is that you need to activate it on the device.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

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