-
Bug
-
Resolution: Done
-
P2: Important
-
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====================================================================================="); } }