-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
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; |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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.
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? |
Yes, that's fine. On that note, would you be interested in adding some doc for it in the bootstraps page? |
Yes, in about three weeks I'll be delivering my MSc thesis of which my contributions to p4a are a part. |
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. |
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).