microg / UnifiedNlp

Alternative network location provider for Android, with plugin interface to easily integrate third-party location providers.
977 stars 210 forks source link

Standalone API example #1

Closed rtreffer closed 10 years ago

rtreffer commented 10 years ago

I'm currently trying to get a backend registered (and working) with the UnifiedNlp - but I have a hard time getting the samples to work as a stand alone application.

Could you provide an example like the random location provider buildable as a standalone apk?

mar-v-in commented 10 years ago

I'm not sure what you want to do.

The sample from /sample/ can be built as an APK (it requires the library from /api/) and provides three sample backends, that can be choosen from the UnifiedNlp settings (this is what can be built from /). You may also take a look at a real backend using data from Apple. As I don't use any of the usual build systems (ant/maven/gradle) there is no config file for such, but it should be fairly easy to create them (or generate them if you're using an IDE). If you want, I'll add a five-line bash script that does the build.

You'll always need at least two APKs to retrieve a location, the system part (must be installed in /system/priv-app on KitKat or /system/app on older Android versions, pre-release binary is here) and a backend (installed as usual). UnifiedNlp is not intended to be a single standalone apk.

The system part will detect an service that has the org.microg.nlp.LOCATION_BACKEND action as a possible backend. Each backend service most respond to the onBind with an binder to the org.microg.nlp.api.LocationBackend interface, if your service extends the org.microg.nlp.api.LocationBackendService, this is done automatically.

rtreffer commented 10 years ago

Thank you very much. I've read through the extended documentation and it answers just about everything I wanted to ask :-)

I still can't get it to work, but I've got a better feeling that I can work it out with the new docs. Please close it.

PS: I'm writing a location provider based on the opencellid data. I'll upload it as soon as I get it to work as a backend.... (although I'll have to see where I put the dump, it's ~60MB - github may dislike that....)

mar-v-in commented 10 years ago

Good to know you're writing the opencellid backend, so I don't have to :)

I assume you use the dump from http://downloads.opencellid.org/ and convert it in some sort of sqlite database, being your 60mb file. Just a suggestion: make the conversion from csv to database part of the app and provide an ui to recreate (=download and convert the latest file) the database. This way you don't need to recreate the database to keep it up-to-date, because everyone does it on his own.

I don't know what's the file size limit for a release on github, but I just tested with a 100MB file and it accepted the upload.

If you continue to have problems, just upload the incomplete stuff and i'll take a look on it :)

rtreffer commented 10 years ago

I'm using a custom binary format because the sqlite was >300MB and I need just key and range lookups, so I've coded a minimal sorted list with an index of 4kb pages.

It's ~50% of the sqlite filesize (both packed and unpacked), <= 1000 LoC for the reader. Anyway, adding the conversion tool as part of the app sounds reasonable (although it's currently horrible scala code)

Well, I'll simply upload it if I can't get it to work by Monday. But I'm quite optimistic (enough sample code + docs)