Discussion:
Android services
(too old to reply)
Jason H
2016-03-04 22:46:58 UTC
Permalink
So I am trying to implement a background service and it's not going very well. The service is being used to upload files when the UI is suspended.

My usage differs from the http://www.kdab.com/qt-android-episode-7/ tutorial in a number of ways.

1. I have a Qt App
2. I have a subclassed QtActivity
3. I have a subclassed IntentService
4. The intent service calls the native statics functions.
5. I've added <service android:name=".MyUploadService" android:exported="false" android:enabled="true"/> to the manifest, and spec'd MyActivity as the activity.


6. MyActivity::onCreate calls:
Intent serviceIntent = new Intent(this, MyUploadService.class);
startService(serviceIntent);

And that's where it stops.

In my MyUploadService,
1. None of the below gets logged:
@Override
public MyUploadService() {
super("MyUploadService");
java.lang.System.out.println(this.getClass().toString() + " Initialized");
}

@Override
public void onCreate() {
java.lang.System.out.println(this.getClass().toString() + " Created");
}

@Override
public void onHandleIntent(Intent workIntent) {
java.lang.System.out.println(this.getClass().toString() + " onHandleIntent");
...
}

Once the service is started, it is occasionally sent messages for work to do. But it doesn't get that far.


Help?
m***@rpzdesign.com
2016-03-04 23:50:25 UTC
Permalink
Why don't you create a skeleton test app and share with the group the
source code.

I sent you a reply message yesterday suggesting the Android Job API.

You might find sweeter fruit using that.

md


On 3/4/2016 4:46 PM, Jason H wrote:
> So I am trying to implement a background service and it's not going very well. The service is being used to upload files when the UI is suspended.
>
> My usage differs from the http://www.kdab.com/qt-android-episode-7/ tutorial in a number of ways.
>
> 1. I have a Qt App
> 2. I have a subclassed QtActivity
> 3. I have a subclassed IntentService
> 4. The intent service calls the native statics functions.
> 5. I've added <service android:name=".MyUploadService" android:exported="false" android:enabled="true"/> to the manifest, and spec'd MyActivity as the activity.
>
>
> 6. MyActivity::onCreate calls:
> Intent serviceIntent = new Intent(this, MyUploadService.class);
> startService(serviceIntent);
>
> And that's where it stops.
>
> In my MyUploadService,
> 1. None of the below gets logged:
> @Override
> public MyUploadService() {
> super("MyUploadService");
> java.lang.System.out.println(this.getClass().toString() + " Initialized");
> }
>
> @Override
> public void onCreate() {
> java.lang.System.out.println(this.getClass().toString() + " Created");
> }
>
> @Override
> public void onHandleIntent(Intent workIntent) {
> java.lang.System.out.println(this.getClass().toString() + " onHandleIntent");
> ...
> }
>
> Once the service is started, it is occasionally sent messages for work to do. But it doesn't get that far.
>
>
> Help?
>
> _______________________________________________
> Interest mailing list
> ***@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
Jason H
2016-03-07 17:27:08 UTC
Permalink
Yes, a skeleton app is the next step.

The problem with the Jobs api is it's api availability, we would either need to use the compat library or up our minimum specs (4.2, API 17)
I'd also like to get services working in Qt in general.


> Sent: Friday, March 04, 2016 at 6:50 PM
> From: "***@rpzdesign.com" <***@rpzdesign.com>
> To: ***@qt-project.org
> Subject: Re: [Interest] Android services
>
> Why don't you create a skeleton test app and share with the group the
> source code.
>
> I sent you a reply message yesterday suggesting the Android Job API.
>
> You might find sweeter fruit using that.
>
> md
>
>
> On 3/4/2016 4:46 PM, Jason H wrote:
> > So I am trying to implement a background service and it's not going very well. The service is being used to upload files when the UI is suspended.
> >
> > My usage differs from the http://www.kdab.com/qt-android-episode-7/ tutorial in a number of ways.
> >
> > 1. I have a Qt App
> > 2. I have a subclassed QtActivity
> > 3. I have a subclassed IntentService
> > 4. The intent service calls the native statics functions.
> > 5. I've added <service android:name=".MyUploadService" android:exported="false" android:enabled="true"/> to the manifest, and spec'd MyActivity as the activity.
> >
> >
> > 6. MyActivity::onCreate calls:
> > Intent serviceIntent = new Intent(this, MyUploadService.class);
> > startService(serviceIntent);
> >
> > And that's where it stops.
> >
> > In my MyUploadService,
> > 1. None of the below gets logged:
> > @Override
> > public MyUploadService() {
> > super("MyUploadService");
> > java.lang.System.out.println(this.getClass().toString() + " Initialized");
> > }
> >
> > @Override
> > public void onCreate() {
> > java.lang.System.out.println(this.getClass().toString() + " Created");
> > }
> >
> > @Override
> > public void onHandleIntent(Intent workIntent) {
> > java.lang.System.out.println(this.getClass().toString() + " onHandleIntent");
> > ...
> > }
> >
> > Once the service is started, it is occasionally sent messages for work to do. But it doesn't get that far.
> >
> >
> > Help?
> >
> > _______________________________________________
> > Interest mailing list
> > ***@qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
> >
>
> _______________________________________________
> Interest mailing list
> ***@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
Pendleton, Corey
2016-03-07 17:46:21 UTC
Permalink
You might find this interesting: https://bugreports.qt.io/browse/QTBUG-37221
According to the patch associated with that report: https://codereview.qt-project.org/#/c/149018/ this feature may be available to you with Qt 5.7.

Corey

-----Original Message-----
From: ***@rpzdesign.com [mailto:***@rpzdesign.com]
Sent: Friday, March 04, 2016 5:50 PM
To: ***@qt-project.org
Subject: Re: [Interest] Android services

Why don't you create a skeleton test app and share with the group the source code.

I sent you a reply message yesterday suggesting the Android Job API.

You might find sweeter fruit using that.

md


On 3/4/2016 4:46 PM, Jason H wrote:
> So I am trying to implement a background service and it's not going very well. The service is being used to upload files when the UI is suspended.
>
> My usage differs from the http://www.kdab.com/qt-android-episode-7/ tutorial in a number of ways.
>
> 1. I have a Qt App
> 2. I have a subclassed QtActivity
> 3. I have a subclassed IntentService
> 4. The intent service calls the native statics functions.
> 5. I've added <service android:name=".MyUploadService" android:exported="false" android:enabled="true"/> to the manifest, and spec'd MyActivity as the activity.
>
>
> 6. MyActivity::onCreate calls:
> Intent serviceIntent = new Intent(this, MyUploadService.class);
> startService(serviceIntent);
>
> And that's where it stops.
>
> In my MyUploadService,
> 1. None of the below gets logged:
> @Override
> public MyUploadService() {
> super("MyUploadService");
> java.lang.System.out.println(this.getClass().toString() + " Initialized");
> }
>
> @Override
> public void onCreate() {
> java.lang.System.out.println(this.getClass().toString() + " Created");
> }
>
> @Override
> public void onHandleIntent(Intent workIntent) {
> java.lang.System.out.println(this.getClass().toString() + " onHandleIntent");
> ...
> }
>
> Once the service is started, it is occasionally sent messages for work to do. But it doesn't get that far.
>
>
> Help?
>
> _______________________________________________
> Interest mailing list
> ***@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



________________________________

CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be confidential and/or legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.
Jason H
2016-03-07 17:55:05 UTC
Permalink
Thanks, but
1. I need it now.
2. "The Android Application running can now have a QtActivity or a QtService, but having both in the same process is not supported."

Both of which are deal-breakers. It's be nice to know if I can work around the limitation of the patch?




> Sent: Monday, March 07, 2016 at 12:46 PM
> From: "Pendleton, Corey" <***@garmin.com>
> To: "***@qt-project.org" <***@qt-project.org>
> Subject: Re: [Interest] Android services
>
> You might find this interesting: https://bugreports.qt.io/browse/QTBUG-37221
> According to the patch associated with that report: https://codereview.qt-project.org/#/c/149018/ this feature may be available to you with Qt 5.7.
>
> Corey
>
> -----Original Message-----
> From: ***@rpzdesign.com [mailto:***@rpzdesign.com]
> Sent: Friday, March 04, 2016 5:50 PM
> To: ***@qt-project.org
> Subject: Re: [Interest] Android services
>
> Why don't you create a skeleton test app and share with the group the source code.
>
> I sent you a reply message yesterday suggesting the Android Job API.
>
> You might find sweeter fruit using that.
>
> md
>
>
> On 3/4/2016 4:46 PM, Jason H wrote:
> > So I am trying to implement a background service and it's not going very well. The service is being used to upload files when the UI is suspended.
> >
> > My usage differs from the http://www.kdab.com/qt-android-episode-7/ tutorial in a number of ways.
> >
> > 1. I have a Qt App
> > 2. I have a subclassed QtActivity
> > 3. I have a subclassed IntentService
> > 4. The intent service calls the native statics functions.
> > 5. I've added <service android:name=".MyUploadService" android:exported="false" android:enabled="true"/> to the manifest, and spec'd MyActivity as the activity.
> >
> >
> > 6. MyActivity::onCreate calls:
> > Intent serviceIntent = new Intent(this, MyUploadService.class);
> > startService(serviceIntent);
> >
> > And that's where it stops.
> >
> > In my MyUploadService,
> > 1. None of the below gets logged:
> > @Override
> > public MyUploadService() {
> > super("MyUploadService");
> > java.lang.System.out.println(this.getClass().toString() + " Initialized");
> > }
> >
> > @Override
> > public void onCreate() {
> > java.lang.System.out.println(this.getClass().toString() + " Created");
> > }
> >
> > @Override
> > public void onHandleIntent(Intent workIntent) {
> > java.lang.System.out.println(this.getClass().toString() + " onHandleIntent");
> > ...
> > }
> >
> > Once the service is started, it is occasionally sent messages for work to do. But it doesn't get that far.
> >
> >
> > Help?
> >
> > _______________________________________________
> > Interest mailing list
> > ***@qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
> >
>
>
>
> ________________________________
>
> CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be confidential and/or legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.
> _______________________________________________
> Interest mailing list
> ***@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
Pendleton, Corey
2016-03-07 18:04:13 UTC
Permalink
Yeah, we have the same challenge. Our current workaround is to launch our Activity as a sticky activity, and then push it to the background after it starts processing events. Hopefully, that keeps it invisible to device users at startup, but gets our service running in-process. It's an ugly hack, but we hope Qt can work on this or perhaps we can help by contributing eventually.

Corey

-----Original Message-----
From: Jason H [mailto:***@gmx.com]
Sent: Monday, March 07, 2016 11:55 AM
To: Pendleton, Corey <***@garmin.com>
Cc: ***@qt-project.org
Subject: Re: [Interest] Android services

Thanks, but
1. I need it now.
2. "The Android Application running can now have a QtActivity or a QtService, but having both in the same process is not supported."

Both of which are deal-breakers. It's be nice to know if I can work around the limitation of the patch?




> Sent: Monday, March 07, 2016 at 12:46 PM
> From: "Pendleton, Corey" <***@garmin.com>
> To: "***@qt-project.org" <***@qt-project.org>
> Subject: Re: [Interest] Android services
>
> You might find this interesting:
> https://bugreports.qt.io/browse/QTBUG-37221
> According to the patch associated with that report: https://codereview.qt-project.org/#/c/149018/ this feature may be available to you with Qt 5.7.
>
> Corey
>
> -----Original Message-----
> From: ***@rpzdesign.com [mailto:***@rpzdesign.com]
> Sent: Friday, March 04, 2016 5:50 PM
> To: ***@qt-project.org
> Subject: Re: [Interest] Android services
>
> Why don't you create a skeleton test app and share with the group the source code.
>
> I sent you a reply message yesterday suggesting the Android Job API.
>
> You might find sweeter fruit using that.
>
> md
>
>
> On 3/4/2016 4:46 PM, Jason H wrote:
> > So I am trying to implement a background service and it's not going very well. The service is being used to upload files when the UI is suspended.
> >
> > My usage differs from the http://www.kdab.com/qt-android-episode-7/ tutorial in a number of ways.
> >
> > 1. I have a Qt App
> > 2. I have a subclassed QtActivity
> > 3. I have a subclassed IntentService 4. The intent service calls the
> > native statics functions.
> > 5. I've added <service android:name=".MyUploadService" android:exported="false" android:enabled="true"/> to the manifest, and spec'd MyActivity as the activity.
> >
> >
> > 6. MyActivity::onCreate calls:
> > Intent serviceIntent = new Intent(this, MyUploadService.class);
> > startService(serviceIntent);
> >
> > And that's where it stops.
> >
> > In my MyUploadService,
> > 1. None of the below gets logged:
> > @Override
> > public MyUploadService() {
> > super("MyUploadService");
> > java.lang.System.out.println(this.getClass().toString() + " Initialized");
> > }
> >
> > @Override
> > public void onCreate() {
> > java.lang.System.out.println(this.getClass().toString() + " Created");
> > }
> >
> > @Override
> > public void onHandleIntent(Intent workIntent) {
> > java.lang.System.out.println(this.getClass().toString() + " onHandleIntent");
> > ...
> > }
> >
> > Once the service is started, it is occasionally sent messages for work to do. But it doesn't get that far.
> >
> >
> > Help?
> >
> > _______________________________________________
> > Interest mailing list
> > ***@qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
> >
>
>
>
> ________________________________
>
> CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be confidential and/or legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.
> _______________________________________________
> Interest mailing list
> ***@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
Jason H
2016-03-07 19:02:10 UTC
Permalink
I am willing to write as much android code as I need That is to say I was hoping to extend QtActivity, and have the QtActivity talk to the service as if it were a proper Android app, as well as code the service in Android SDK. I have the luxury of being able to mostly coordinate things through the database (save for kicking off the service) so I think I should be ok. But MyActivity (extends QtActivity) does not seem to start the service, even with startIntent() (The service class, extending IntentService never even gets created!?)


> Sent: Monday, March 07, 2016 at 1:04 PM
> From: "Pendleton, Corey" <***@garmin.com>
> To: "Jason H" <***@gmx.com>
> Cc: "***@qt-project.org" <***@qt-project.org>
> Subject: RE: [Interest] Android services
>
> Yeah, we have the same challenge. Our current workaround is to launch our Activity as a sticky activity, and then push it to the background after it starts processing events. Hopefully, that keeps it invisible to device users at startup, but gets our service running in-process. It's an ugly hack, but we hope Qt can work on this or perhaps we can help by contributing eventually.
>
> Corey
>
> -----Original Message-----
> From: Jason H [mailto:***@gmx.com]
> Sent: Monday, March 07, 2016 11:55 AM
> To: Pendleton, Corey <***@garmin.com>
> Cc: ***@qt-project.org
> Subject: Re: [Interest] Android services
>
> Thanks, but
> 1. I need it now.
> 2. "The Android Application running can now have a QtActivity or a QtService, but having both in the same process is not supported."
>
> Both of which are deal-breakers. It's be nice to know if I can work around the limitation of the patch?
>
>
>
>
> > Sent: Monday, March 07, 2016 at 12:46 PM
> > From: "Pendleton, Corey" <***@garmin.com>
> > To: "***@qt-project.org" <***@qt-project.org>
> > Subject: Re: [Interest] Android services
> >
> > You might find this interesting:
> > https://bugreports.qt.io/browse/QTBUG-37221
> > According to the patch associated with that report: https://codereview.qt-project.org/#/c/149018/ this feature may be available to you with Qt 5.7.
> >
> > Corey
> >
> > -----Original Message-----
> > From: ***@rpzdesign.com [mailto:***@rpzdesign.com]
> > Sent: Friday, March 04, 2016 5:50 PM
> > To: ***@qt-project.org
> > Subject: Re: [Interest] Android services
> >
> > Why don't you create a skeleton test app and share with the group the source code.
> >
> > I sent you a reply message yesterday suggesting the Android Job API.
> >
> > You might find sweeter fruit using that.
> >
> > md
> >
> >
> > On 3/4/2016 4:46 PM, Jason H wrote:
> > > So I am trying to implement a background service and it's not going very well. The service is being used to upload files when the UI is suspended.
> > >
> > > My usage differs from the http://www.kdab.com/qt-android-episode-7/ tutorial in a number of ways.
> > >
> > > 1. I have a Qt App
> > > 2. I have a subclassed QtActivity
> > > 3. I have a subclassed IntentService 4. The intent service calls the
> > > native statics functions.
> > > 5. I've added <service android:name=".MyUploadService" android:exported="false" android:enabled="true"/> to the manifest, and spec'd MyActivity as the activity.
> > >
> > >
> > > 6. MyActivity::onCreate calls:
> > > Intent serviceIntent = new Intent(this, MyUploadService.class);
> > > startService(serviceIntent);
> > >
> > > And that's where it stops.
> > >
> > > In my MyUploadService,
> > > 1. None of the below gets logged:
> > > @Override
> > > public MyUploadService() {
> > > super("MyUploadService");
> > > java.lang.System.out.println(this.getClass().toString() + " Initialized");
> > > }
> > >
> > > @Override
> > > public void onCreate() {
> > > java.lang.System.out.println(this.getClass().toString() + " Created");
> > > }
> > >
> > > @Override
> > > public void onHandleIntent(Intent workIntent) {
> > > java.lang.System.out.println(this.getClass().toString() + " onHandleIntent");
> > > ...
> > > }
> > >
> > > Once the service is started, it is occasionally sent messages for work to do. But it doesn't get that far.
> > >
> > >
> > > Help?
> > >
> > > _______________________________________________
> > > Interest mailing list
> > > ***@qt-project.org
> > > http://lists.qt-project.org/mailman/listinfo/interest
> > >
> >
> >
> >
> > ________________________________
> >
> > CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be confidential and/or legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.
> > _______________________________________________
> > Interest mailing list
> > ***@qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
> >
>
Continue reading on narkive:
Loading...