1

The android docs on Bound Services show "no access modifier", resulting in package level scope when defining getService(). For example:

<!-- language: lang-java  -->
public class LocalBinder extends Binder {
    LocalService getService() {
        return LocalService.this;
    }
}

I am working on refactoring my code into packages, so I may re-use it in another app, but have hit compile errors stating, "method getService() from the type foo.LocalBinder is not visible".

I've not been able to find the reference declaration of getService(). Am I risking running into problems if I open the scope, such as:

<!-- language: lang-java  -->
public LocalService getService() {
...

I am only using the service locally within my own app, and I have android:exported="false" declared in my AndroidManifest.xml.

Community
  • 1
  • 1
donfede
  • 734
  • 1
  • 9
  • 25
  • At this point, I'm banking that it is OK... will report if I hit a bump. – donfede Dec 18 '12 at 00:09
  • After running into your problem, I think you're writing this program the right way... probably. The worst case scenario is some other app grabs ahold of your app's service, but that doesn't seem too likely given Android's propensity to keep apps "secure." I have found at least one example online that demonstrates a public "getService" for the binder: http://dharmendra4android.blogspot.com/2012/05/bind-service-using-ibinder-class.html –  Apr 30 '13 at 19:28

0 Answers0