Java Question android.content.Context.getPackageName() problem

DonManfred

Expert
Licensed User
Longtime User
I am wrapping a Lib which used a Service. It crashes when i try to connect in the Lib.
In the connect the lib starts the Service.
Inside the Service there is a Method which uses getBaseContext() but it crashes at this line in the Service:

B4X:
    private void LoadPreferences(Boolean NotifyOfChanges) {
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
The
B4X:
getBaseContext()
seems to be from the Android Activity or so. don´t know exactly.
maybe android.content.ContextWrapper


The Source of the Service is attached.

Any hints how i can change the Service to get the right reference to the b4a Activity?
 

Attachments

  • ntrip.zip
    15.6 KB · Views: 434

DonManfred

Expert
Licensed User
Longtime User
I tried this but i ran into the same error.


My fear is that this Service depends on an old android version (maybe). The source i found is from 2012.
Or maybe the Android Activity was different in the past.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…