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. Can't listen to android OS intents. ex.RECEIVE_BOOT_COMPLETED
Forum Updated to NodeBB v4.3 + New Features

Can't listen to android OS intents. ex.RECEIVE_BOOT_COMPLETED

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 1.8k 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
    Mena
    wrote on last edited by
    #1

    I have an android service that runs when i open my app, now I want my android service to run at boot time.

    I added these permissions to the manifest:

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.RECEIVE_HEADSET_PLUG"/>
    

    Here's my receiver in the manifest:

    <receiver android:name="org.qtproject.example.MyBroadcastReceiver">
      <intent-filter>
      <action android:name="android.intent.action.RECEIVE_BOOT_COMPLETED"/>
      <action android:name="android.intent.action.RECEIVE_HEADSET_PLUG"/>
      </intent-filter>
     </receiver>
    

    And here's MyBroadcastReceiver.java:

    import android.os.Bundle;
    import org.qtproject.qt5.android.bindings.QtActivity;
    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    
    public class MyBroadcastReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            Intent startServiceIntent = new Intent(context, org.qtproject.example.MyCustomAppService.class);
            context.startService(startServiceIntent);
    
        }
    }
    
    jsulmJ 1 Reply Last reply
    0
    • M Mena

      I have an android service that runs when i open my app, now I want my android service to run at boot time.

      I added these permissions to the manifest:

      <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
      <uses-permission android:name="android.permission.RECEIVE_HEADSET_PLUG"/>
      

      Here's my receiver in the manifest:

      <receiver android:name="org.qtproject.example.MyBroadcastReceiver">
        <intent-filter>
        <action android:name="android.intent.action.RECEIVE_BOOT_COMPLETED"/>
        <action android:name="android.intent.action.RECEIVE_HEADSET_PLUG"/>
        </intent-filter>
       </receiver>
      

      And here's MyBroadcastReceiver.java:

      import android.os.Bundle;
      import org.qtproject.qt5.android.bindings.QtActivity;
      import android.content.BroadcastReceiver;
      import android.content.Context;
      import android.content.Intent;
      
      public class MyBroadcastReceiver extends BroadcastReceiver {
          @Override
          public void onReceive(Context context, Intent intent) {
              Intent startServiceIntent = new Intent(context, org.qtproject.example.MyCustomAppService.class);
              context.startService(startServiceIntent);
      
          }
      }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Mena And what is the problem?
      "Can't listen to android OS intents. ex.RECEIVE_BOOT_COMPLETED" - does not tell much. What exactly is happening?

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

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Mena And what is the problem?
        "Can't listen to android OS intents. ex.RECEIVE_BOOT_COMPLETED" - does not tell much. What exactly is happening?

        M Offline
        M Offline
        Mena
        wrote on last edited by
        #3

        @jsulm The service does not start. No errors or anything. I can't see it running on my android phone neither after booting or after plugging a headset.
        However, if I start it from my application, it starts and i can see it running in the services on my phone.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mena
          wrote on last edited by
          #4

          ok , I was able to solve the problem!
          Here's the solution:
          https://stackoverflow.com/a/44353506/8086424

          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