Skip to content

Improve service_only bootstrap #845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 30, 2016
Merged

Improve service_only bootstrap #845

merged 9 commits into from
Jul 30, 2016

Conversation

brussee
Copy link
Contributor

@brussee brussee commented Jul 19, 2016

  • 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
Copy link
Contributor Author

brussee commented Jul 21, 2016

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

@@ -136,7 +131,6 @@ public void onDestroy() {
@Override
public void run() {
PythonUtil.loadLibraries(getFilesDir());
mService = this;
Copy link
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
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
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)?

Copy link
Contributor Author

@brussee brussee Jul 29, 2016

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
Copy link
Contributor Author

brussee commented Jul 29, 2016

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
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
Copy link
Contributor Author

brussee commented Jul 31, 2016

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

@brussee
Copy link
Contributor Author

brussee commented Oct 18, 2016

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