Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-62644

Unable to stop Android Service when using QtRemoteObject

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.11.0
    • 5.9.1
    • None
    • Qt 5.9.1 gcc 4.9 armeabi-v7a. 

      Android minsdkversion 19, targetsdkversion 19, build sdk 25. 

      I'm unable to stop a background android service started using Qt Remote Objects. 

      I just followed the tutorial presented by KDAB (https://www.kdab.com/qt-android-create-android-service-using-qt/) and started the service on demand in main.cpp. When onDestroy is called on Android, I get the message below

       

      Service com.tezine.myapp.MyService has leaked IntentReceiver org.qtproject.qt5.android.bearer.QtNetworkReceiver$BroadcastReceiverPrivate@ceb4c25 that was originally registered here. Are you missing a call to unregisterReceiver()? android.app.IntentReceiverLeaked: Service com.tezine.myapp.MyService has leaked IntentReceiver org.qtproject.qt5.android.bearer.QtNetworkReceiver$BroadcastReceiverPrivate@ceb4c25 that was originally registered here. Are you missing a call to unregisterReceiver()? at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:918) at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:719) at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1172) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1152) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1146) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:554) at org.qtproject.qt5.android.bearer.QtNetworkReceiver.registerReceiver(QtNetworkReceiver.java:73)

       

      This is how I'm trying to stop the service. (From a cpp inside service)

       

      QtAndroid::androidService().callMethod<void>("stopSelf");

      The service doesn't stop and the background processs is not destroyed . 

       

      Follow the MyService.java below;

       

      public class MyService extends QtService {
      //region Fields
       private static final String TAG = "MyService";
       private static final String OnCreate="onCreate";
       //endregion
      //region onCreate
       @Override
       public void onCreate() {
       super.onCreate();
       System.out.println("(MyService)onCreate=========================================================================================");
       }
       //endregion
      //region startMyService
       public static void startMyService(Context ctx) {
       ctx.startService(new Intent(ctx, MyService.class));
       System.out.println("(MyService)startMyService===================================================================================");
       }
       //endregion
      @Override
       public void onDestroy() {
       super.onDestroy();
       System.out.println("(MyService)ondestroy=====================================================================================");
       }
      }
      

       

       

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            taipan BogDan Vatra
            tezine Bruno Tezine
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes