Skip to content

Improve service_only bootstrap#845

Merged
inclement merged 9 commits into
kivy:masterfrom
brussee:service_only
Jul 30, 2016
Merged

Improve service_only bootstrap#845
inclement merged 9 commits into
kivy:masterfrom
brussee:service_only

Conversation

@brussee

@brussee brussee commented Jul 19, 2016

Copy link
Copy Markdown
Contributor
  • Add option to have a different icon for the python service.
  • Bugfix bootstrap Gradle build script
  • Binder interface

Because it will be shown in the notification bar in black and white you likely want to use a different icon than the colored app one, since Android forces that one to black and white otherwise (ugly).

@brussee brussee changed the title Service icon option Bugfix bootstrap Gradle build script + Service icon option Jul 21, 2016
@brussee

brussee commented Jul 21, 2016

Copy link
Copy Markdown
Contributor Author

Now also contains a bugfix to install the *.gradle build scripts included with the service_only bootstrap: db26263

@Override
public void run() {
PythonUtil.loadLibraries(getFilesDir());
mService = this;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the mService stuff? Is this because it no longer makes sense when multiple services can run at once? (Honest question, I haven't used the services).

Looks good otherwise, thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. Unless you need something to be a singleton, using static variables to hold instances of classes is not what you want.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that some users may be using a single service and relying on this method of accessing it, as that's the way the old toolchain worked. Would you be terribly disappointed if I merged this but added mService back in for now (at least until after it's clearly deprecated)?

@brussee brussee Jul 29, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your concern because of the change of behavior with regard to the old tool-chain.
The solution to this is a binder: https://developer.android.com/guide/components/bound-services.html

Example from http://stackoverflow.com/a/24541584

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class MyService extends Service {
    private Binder binder;  

    @Override
    public void onCreate() {
        super.onCreate();
        binder = new Binder();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return binder;
    }

    public class Binder extends android.os.Binder {
        public MyService getService() {
            return MyService.this;
        }
    }
}

I will add this to my service_only bootstrap, because the static variable is a bug if you have multiple services.

@brussee brussee changed the title Bugfix bootstrap Gradle build script + Service icon option Improve service_only bootstrap Jul 29, 2016
@brussee

brussee commented Jul 29, 2016

Copy link
Copy Markdown
Contributor Author

I will add this to my service_only bootstrap, because the static variable is a bug if you have multiple services.

Done! Enjoy!

By the way: this new bootstrap is only available since the new tool-chain, so as long as the differences are documented it will probably be fine, right?

@inclement

Copy link
Copy Markdown
Member

Yes, that's fine. On that note, would you be interested in adding some doc for it in the bootstraps page?

@inclement inclement merged commit dd68e61 into kivy:master Jul 30, 2016
@brussee

brussee commented Jul 31, 2016

Copy link
Copy Markdown
Contributor Author

Yes, in about three weeks I'll be delivering my MSc thesis of which my contributions to p4a are a part.

@brussee

brussee commented Oct 18, 2016

Copy link
Copy Markdown
Contributor Author

Sorry for the delay. I'll try to write documentation about how use this bootstrap at some point, especially how to work with the .gradle build template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants