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. Start android service at boot time
QtWS25 Last Chance

Start android service at boot time

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 2 Posters 2.3k 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.
  • M Offline
    M Offline
    Montjet
    wrote on 28 Nov 2018, 10:31 last edited by Montjet
    #1

    Hi,
    I have problem with implement starting the android service at boot time.
    I used code from this url: https://github.com/KDAB/android

    And my code: https://ufile.io/r7lfm
    Service is not starting.
    What's wrong with my code?

    R 1 Reply Last reply 28 Nov 2018, 11:43
    0
    • M Montjet
      28 Nov 2018, 10:31

      Hi,
      I have problem with implement starting the android service at boot time.
      I used code from this url: https://github.com/KDAB/android

      And my code: https://ufile.io/r7lfm
      Service is not starting.
      What's wrong with my code?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 28 Nov 2018, 11:43 last edited by
      #2

      @Montjet
      This doesn't make much sense:

      <receiver android:name=".MyActivity">
              <intent-filter>
                  <action android:name="android.intent.action.BOOT_COMPLETED" />
              </intent-filter>
      </receiver>
      

      You should rather connect this to a BroadcastReceiver class. Also you need to specify the android.permission.RECEIVE_BOOT_COMPLETED in your manifest

      I guess you have the corresponding warnings/errors in your logcat.

      Take a look at:
      https://www.kdab.com/qt-android-create-android-service-using-qt/

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Montjet
        wrote on 28 Nov 2018, 12:00 last edited by Montjet
        #3
        You should rather connect this to a BroadcastReceiver class. Also you need to specify the android.permission.RECEIVE_BOOT_COMPLETED in your manifest
        

        I specified this permission - 3 line.

        This doesn't make much sense:
        
        <receiver android:name=".MyActivity">
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED" />
                </intent-filter>
        </receiver>
        

        MyActivity extends BroadcastReceiver class.

        #edit
        Logcat log:

        D/PackageManager(  848): scan package: /data/app/com.kdab.training-1 , start at: 39745ms.
        
        D/PackageManager(  848): Parsing: /data/app/com.kdab.training-1
        
        I/PackageManager(  848): Linking native library dir for /data/app/com.kdab.training-1
        
        I/PackageManager(  848): Perform pre-dex opt for package: com.kdab.training
        
        D/PackageManager(  848): scan package: /data/app/com.kdab.training-1 , end at: 39925ms. elapsed time = 180ms.
        

        And nothing more.

        #edit2
        I found error:

        W/PackageParser(  846): Unknown element under <application>: uses-permission at /data/app/com.kdab.training-1/base.apk Binary XML file line #153
        
        R 1 Reply Last reply 28 Nov 2018, 12:36
        0
        • M Montjet
          28 Nov 2018, 12:00
          You should rather connect this to a BroadcastReceiver class. Also you need to specify the android.permission.RECEIVE_BOOT_COMPLETED in your manifest
          

          I specified this permission - 3 line.

          This doesn't make much sense:
          
          <receiver android:name=".MyActivity">
                  <intent-filter>
                      <action android:name="android.intent.action.BOOT_COMPLETED" />
                  </intent-filter>
          </receiver>
          

          MyActivity extends BroadcastReceiver class.

          #edit
          Logcat log:

          D/PackageManager(  848): scan package: /data/app/com.kdab.training-1 , start at: 39745ms.
          
          D/PackageManager(  848): Parsing: /data/app/com.kdab.training-1
          
          I/PackageManager(  848): Linking native library dir for /data/app/com.kdab.training-1
          
          I/PackageManager(  848): Perform pre-dex opt for package: com.kdab.training
          
          D/PackageManager(  848): scan package: /data/app/com.kdab.training-1 , end at: 39925ms. elapsed time = 180ms.
          

          And nothing more.

          #edit2
          I found error:

          W/PackageParser(  846): Unknown element under <application>: uses-permission at /data/app/com.kdab.training-1/base.apk Binary XML file line #153
          
          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 28 Nov 2018, 12:36 last edited by
          #4

          @Montjet said in Start android service at boot time:

          MyActivity extends BroadcastReceiver class.

          oh k.

          anyway. There must be more than 5 lines in the logcat ouput.
          How are you testing exactly?

          What API version are you building against and also executing on?

          Since Android 7.0 (API 24) some broadcast receivers must to be registered from code.
          https://developer.android.com/guide/components/broadcast-exceptions
          Seems android.intent.action.BOOT_COMPLETED is not part of it, but it is also named differently: ACTION_BOOT_COMPLETED

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          M 1 Reply Last reply 28 Nov 2018, 13:07
          0
          • R raven-worx
            28 Nov 2018, 12:36

            @Montjet said in Start android service at boot time:

            MyActivity extends BroadcastReceiver class.

            oh k.

            anyway. There must be more than 5 lines in the logcat ouput.
            How are you testing exactly?

            What API version are you building against and also executing on?

            Since Android 7.0 (API 24) some broadcast receivers must to be registered from code.
            https://developer.android.com/guide/components/broadcast-exceptions
            Seems android.intent.action.BOOT_COMPLETED is not part of it, but it is also named differently: ACTION_BOOT_COMPLETED

            M Offline
            M Offline
            Montjet
            wrote on 28 Nov 2018, 13:07 last edited by Montjet
            #5

            @raven-worx said in Start android service at boot time:

            anyway. There must be more than 5 lines in the logcat ouput.
            How are you testing exactly?

            Command: "./adb -d logcat > log.txt".
            I included only logs containing "com.kdab.training".

            @raven-worx said in Start android service at boot time:

            What API version are you building against and also executing on?

            API level 27.
            Android 5.1 Lollipop.
            SDK Version: 26.1.1.
            NDK Version: 16.1.4479499.
            Qt: 5.11.2.

            #edit
            I changed API level to 22, but service still doesn't start.

            #edit2
            New warning:

            W/PackageManager( 2573): Failure retrieving resources for com.kdab.training: Resource ID #0x0
            

            #edit3
            Application is tested on phone with installed MIUI.
            For some reason application have not permission to autostart - startup manager, so RECEIVE_BOOT_COMPLETED permission still is not granted ;/

            1 Reply Last reply
            0

            1/5

            28 Nov 2018, 10:31

            • Login

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