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. Android stop service from C++
QtWS25 Last Chance

Android stop service from C++

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
android serviceserviceactivity
2 Posts 2 Posters 538 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.
  • U Offline
    U Offline
    UxoriousGhost
    wrote on 1 Mar 2022, 17:25 last edited by UxoriousGhost 3 Jan 2022, 17:27
    #1

    By referring to examples I'm able to start a service by calling "startService" method. But I'm not able to Stop the service.
    My code to start service is

    QAndroidIntent serviceIntent(QtAndroid::androidActivity().object(),"myService");
        serviceIntent.putExtra("name", name.toUtf8());
        QAndroidJniObject result = QtAndroid::androidActivity().callObjectMethod(
                    "startService",
                    "(Landroid/content/Intent;)Landroid/content/ComponentName;",
                    serviceIntent.handle().object());
    

    Code to stop the service

    QAndroidIntent serviceIntent(QtAndroid::androidActivity().object(),"myService");
        QAndroidJniObject result = QtAndroid::androidActivity().callObjectMethod(
                    "stopService",
                    "(Landroid/content/Intent;)Z;",
                    serviceIntent.handle().object());
    

    I'm getting error of no such method in android

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrdebug
      wrote on 2 Mar 2022, 07:40 last edited by
      #2

      Please have a look
      https://github.com/denisgottardello/QtAndroidServiceExternalLib
      where you can find how to start and stop a service

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      0

      1/2

      1 Mar 2022, 17:25

      • Login

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