Error LocationMobile.requestMobileLocation

Vincenzo

Member
Licensed User
Longtime User
hi,
I read that some devices (and AVD manager) did not handle the class
LocationManager.
In fact, when I call this:
LocationMobile.requestMobileLocation
goes into exception.

I wanted to see if the system could handle this error, but I have problems
with the following call:

r.Target=r.RunStaticMethod("android.location.Locat ionManager",
"isProviderEnabled", Array As Object("android.location.LocationManager.
NETWORK_PROVIDER"), Array As String("java.lang.String"))

I should do something like this:
If (LocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
LocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
LocationMobile.requestMobileLocation
}


can you help me?
 

Vincenzo

Member
Licensed User
Longtime User
thanks,

I tried but I get this error:
java.lang.NullPointerException: expected receiver of type android.location.LocationManager, but got null

and do not understand how to solve.
 
Upvote 0

Vincenzo

Member
Licensed User
Longtime User
Solution

Dim r As Reflector
r.Target = r.GetContext
r.Target =r.RunMethod2 ("getSystemService", "location", "java.lang.String")
Log(" enabled ? "&r.RunMethod2("isProviderEnabled", "network", "java.lang.String"))


work,
but it is a bit bad not being able to use the constants.
Do you know how can I update it?
thanks:cool:
 
Last edited:
Upvote 0

Vincenzo

Member
Licensed User
Longtime User
I'm sorry,
I wanted to say
instead of "network" string I would use android.location.LocationManager.NETWORK_PROVIDER
 
Upvote 0

Vincenzo

Member
Licensed User
Longtime User
Code

Dim r As Reflector
r.Target = r.GetContext
r.Target =r.RunMethod2 ("getSystemService", "location", "java.lang.String")
Log("enabled ? "&Return r.RunMethod2("isProviderEnabled", r.GetField("NETWORK_PROVIDER"), "java.lang.String")) :sign0060:
 
Upvote 0
Top