B4A Library Unwired LocationAPI Android Library

Hi,

The attached lib is a wrapper for this github project.

The Unwired Labs' LocationAPI locates all sorts of devices based on cell towers, WiFi APs and IP addresses, anywhere in the world. LocationAPI works both indoors & outdoors, when GPS isn't available or preferred (high battery drain).

The new Android library is a drop-in replacement to Google Play's Geolocation services and offers the following benefits:

  • Offline location - now you can ask for the device's location and get a location in milliseconds even if the device has no or slow internet access.

  • Higher accuracy - Unwired's Geolocation triangulation & trilateration algorithms are far superior to Google's 'nearest-cell' based locations. This means no more locations in the sea and also, locations that are much closer to the device's real location.

  • One-time permission request - Unlike the Play Service library, the Unwired library works even when location is off, so your app can locate during events / emergencies, improving User Experience while ensuring that your location logic does not break. Note that you must ensure the end user is aware of this feature and consents to its usage.

  • <coming-soon> HTTP callbacks to your server - We can send the device's location along with some custom tags / data to your server straight from the library or our servers with end-to-end encryption. This saves you the trouble of having to build & maintain secure device <> server communications.

  • <coming-soon> Offline street addresses, Location updates, Geofencing, Context-data model

Register here and obtain a token before using the lib.

B4X:
https://unwiredlabs.com/home
 

Attachments

  • ARLocationAPI.zip
    70.2 KB · Views: 314

Derek Johnson

Active Member
Licensed User
Longtime User
I registered and obtained a token and then I tried to use the demo. I copied the 3 files in the lib folder to the Additional Libraries folder and extracted the src files to a normal project folder.

***** Problem Resolved ******
I've found the cause of this problem. It needs the AppCompat Library, despite there being no apparent references to it in the code. See Post #9
=====================



I replaced the token that I obtained and put it here: (This is not the actual token value!)

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim locationApi As ARLocationApi
    locationApi.Initialize("943eabdeefdd74")
    locationApi.clearCache

On starting the App I got the following log:

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 337)
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/unwiredlabs/locationapi/Location/LocationAdapter;
at ir.aminrezaei.arlocationapi.ARLocationAdapter.Initialize(ARLocationAdapter.java:29)
at ar.locationapi.main._activity_create(main.java:337)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at ar.locationapi.main.afterFirstLayout(main.java:102)
at ar.locationapi.main.access$000(main.java:17)
at ar.locationapi.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: com.unwiredlabs.locationapi.Location.LocationAdapter
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/app/Fragment;
... 14 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.app.Fragment" on path: DexPathList[[zip file "/data/app/ar.locationapi-RVawA4OiD7-gbJlUDRzW8A==/base.apk"],nativeLibraryDirectories=[/data/app/ar.locationapi-RVawA4OiD7-gbJlUDRzW8A==/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 14 more
read: unexpected EOF!

Am I missing something?

The phone is Nexus 5X running Android 8.0.0

P.S. Same result on Android Tabler running 5.1.1

Derek
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
P.S. Same result on Android Tabler running 5.1.1
You are using WHICH android.jar Version (from which platform) inside your Ide (to copmpile)? Use Android.jar from Api 25+
 
Last edited:

Derek Johnson

Active Member
Licensed User
Longtime User
You are using WHICH android.jar Version (from which platform) inside your Ide (to copmpile)? Use Android.jar from Api 25+

Don,

Thanks for your reply. I was using 25, I'll try 26.





Derek
 

Attachments

  • upload_2017-10-10_13-24-21.png
    upload_2017-10-10_13-24-21.png
    17.3 KB · Views: 220

Derek Johnson

Active Member
Licensed User
Longtime User
I've found the cause of the problem. It needs the AppCompat Library. This was an included Library Reference in the project, but the compiler gave a Warnng:
Library 'AppCompat' is not used (warning #32).

So I foolishly removed it, not realising there was an internal dependency.
 

Alexander Stolte

Expert
Licensed User
Longtime User
The library is not working on a service, i have this error:

B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 37 (Starter)
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.SharedPreferences android.content.Context.getSharedPreferences(java.lang.String, int)' on a null object reference
    at com.unwiredlabs.locationapi.Location.LocationAdapter.<init>(Unknown Source)
    at ir.aminrezaei.arlocationapi.ARLocationAdapter.Initialize(ARLocationAdapter.java:29)
    at ar.locationapi.starter._getposi(starter.java:156)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA$2.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6692)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

The project is here.
 
Top