B4A Library Mock-LocationProvider Lib

Hi all,

I've written a small mock-locationProvider-library for B4A in java.

In this case I have to say thank You for all mates, who described the how to build a a4b-lib! - It was my second try of making an own lib in eclipse...
... and had great succes:)

If anyone is interested in further informations about my lib, let me know it.


regards

bitstra

Edit: uploaded library (1.0) with demo project :)

The demo code is well commented.



The moclocationprovider - library devlivers 3 public void() out of java-lib.
1. enableMockProvider(...)
2. publishMockLocation(............)
3. disableMockLocation(...)

If u test it, have a look to all comments in the sample procet code, about using the lib.
Also have look to code structure in ServiceModule (Timer_Tick), for calling publishMockLocation().

After using the sample you have to reboot your device, because my lib functions use the system GPS_PROVIDER name by android os.
!!!Without reboot the buildin gps-hardware can't deliver location data to the system!!!


bye

bitstra
 

Attachments

  • MLPservice.zip
    30.9 KB · Views: 1,115
Last edited:

rbsoft

Active Member
Licensed User
Longtime User
If anyone is interested in further informations about my lib, let me know it.
bitstra

From the name Mock Location I assume the library can provide locations from a file in case there is no GPS fix available, right? That certainly would be very interesting. On Windows Mobile I used Franson's GpsGate (GpsGate Client - Products - GpsGate.com) for this. But that is not available for Android.

I'd like to find out more about that.

Rolf
 

bitstra

Member
Licensed User
Longtime User
Mock.LocationProvider (working in progress)

@Erel,

O.K. - I have to clean some b4a code sample calls for documentation. Then I will upload a V1.0 of the lib with a small sample project next week.
I have to thank you ones more for your great work here - and for your impulses, to get make own written libs working:)

@rbsoft

Yes, you can provide locations-, altitude-, speed-, bearing-data from a file - or like I 'm doing for my first projekt from a device input data stream (i.e. bluetooth-gps...) :)


regards

bitstra
 

rbsoft

Active Member
Licensed User
Longtime User
Great, I am looking forward to it.

Rolf
 

bitstra

Member
Licensed User
Longtime User
MLPdemo uploaded

Hi erel, Hi folks,

I hope it is O.K. that I've attached my ZIP file with the mockLocationProvider library and the demo project to first post?!

Don't know, if it is in the right place there??? :)

...was my first succesfull strike in writing and publishing B4A-libraries.


Hope, it will be usefull for someone...


So - look in OP for uploaded Attachment

regards

bitstra
 
Last edited:

rbsoft

Active Member
Licensed User
Longtime User
Thanks a lot. I will try it out.

Just a little hint - you should build the zip file with B4A. Menu <File><Export as Zip>, like that you get a very small zip file with just the necessary project files and not the generated files.

Rolf
 

bitstra

Member
Licensed User
Longtime User
Thanks a lot. I will try it out.

Just a little hint - you should build the zip file with B4A. Menu <File><Export as Zip>, like that you get a very small zip file with just the necessary project files and not the generated files.

Rolf

thanx - didn't realized that:)

bitstra

(BTW Rolf sounds german - I'm Reinhard :) )
 

rbsoft

Active Member
Licensed User
Longtime User
(BTW Rolf sounds german - I'm Reinhard :) )

It is, see profile.

BTW, the code of the sample project is corrupted. Part of it is missing. You might want to check that out.

Line 59:
B4X:
MLPservice.my_mlp.publishMockLocation(

Parameters are missing.

Rolf
 
Last edited:

bitstra

Member
Licensed User
Longtime User
It is, see profile.

BTW, the code of the sample project is corrupted. Part of it is missing. You might want to check that out.

Rolf


Sorry,

New zip is uploaded.
now I've used the EXPORT ZIP menu from within b4a. Hope - now the code is useable.

BTW, if u use the MLPdemo.apk out of the first coruppted ZIP, than you could see, where I live:) - also didn't realized that :(

thanx in advance and

regards

bitstra
 
Last edited:

rbsoft

Active Member
Licensed User
Longtime User
Still the same error on line 59.

Rolf
 

bitstra

Member
Licensed User
Longtime User
Still the same error on line 59.

Rolf


Now is the update code in the ZIP!

You don't have to download the update zip ones more -

simply delete the line, you have marke above - (Leiche aus Kommentar...sorry )


reagards


bitstra
 

rbsoft

Active Member
Licensed User
Longtime User
Works excellent now!

Rolf
 

pchewn

New Member
Licensed User
Longtime User
Lattitude and Longitude format not proper?

B4X:
latitude="5234.1421"      'lat. as decimal_degrees
  ns="N"               'north-south = NORTH
  longitude="01311.7996"      'long. as decimal_degrees
  we = "E"               'west-east = EAST

The above code is in your "MLPservice" module and does in fact provide a mock GPS location for:

Latitude = 52 degrees 34.1421 minutes
Longitude = 13 degrees 11.7996 minutes

Most of the GPS routines expect Lattitude and Longitude to be in either decimal degrees like: 12.500000

OR

degrees, minutes, decimal minutes like: 12:30.000


It would be nice if the mock location service would follow the normal format for other latitude and longitude formats.

Here are example formats from the GPS library:
B4X:
Initialize2 (Latitude As String, Longitude As String)
Initializes the location object with the given Latitude and Longitude.
Values can be formatted in any of the three formats:
Degrees: [+-]DDD.DDDDD
Minutes: [+-]DDD:MM.MMMMM (Minute = 1 / 60 of a degree)
Seconds: [+-]DDD:MM:SS.SSSSS (Second = 1 / 3600 of a degree)
Example:
Dim L1 As Location
L1.Initialize2("45:30:30", "45:20:15")


Or at least the comments in the code should match what is actually done with the value.
 
Last edited:

schimanski

Well-Known Member
Licensed User
Longtime User
Hello!

I want to use the mock-location provider in my app, but I always have the following exception:

B4X:
java.lang.SecurityException:
Requires ACCESS_MOCK_LOCATION permission

I have tested the demo-app and it run's perfect on the same device. I have also change the manifest with the two lines

B4X:
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
,

but no result:BangHead:

Did anybody knows the problem?

Thanks for help...

This is the log:

java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION permission
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.location.ILocationManager$Stub$Proxy.addTestProvider(ILocationManager.java:1047)
at android.location.LocationManager.addTestProvider(LocationManager.java:1223)
at esolutions4you.B4A.moclocationprovider.moclocationprovider.enableMockProvider(moclocationprovider.java:42)
at Foxfinder.Version_1_0.main._dialogkarte_click(main.java:1196)
at Foxfinder.Version_1_0.main._karte_oeffnen(main.java:2338)
at Foxfinder.Version_1_0.main._blisteinstellung_itemclick(main.java:751)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at anywheresoftware.b4a.BA$2.run(BA.java:268)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5118)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION permission
 
Last edited:
Top