In my app I have some objects with gps positions. At the moment the only thing I do with them is showing them on a map but I plan to implement other features which need to know the users location. I don't want to add the location permission to my app because some users may not want to use these features.
My idea was to have a separate apk (a kind of plugin) which only supplies the main app with location information so that only the plugin needs to request the location permission.
Is it possible to let the plugin share a system service (the LocationManager) directly without creating a custom service with an incompatible interface so that the main app can use the LocationManager of the plugin. This would make it possible to use existing classes like MyLocationOverlay or others. The main app could pass a ContextWrapper to these classes like this:
public static class LocationContext extends ContextWrapper {
public LocationContext(Context base) {
super(base);
}
@Override
public Object getSystemService(String name) {
if (name.equals(LOCATION_SERVICE)) {
// Return the LocationManager service of the plugin here...
}
return super.getSystemService(name);
}
}