I'm trying this error message:
java.lang.RuntimeException: Method: isMockLocationOn not found in: android.app.Application
I try the function that gives an error in the STARTER service and that is where I use it.
What could be wrong?
This is my code inside the STARTER
(
java.lang.RuntimeException: Method: isMockLocationOn not found in: android.app.Application
I try the function that gives an error in the STARTER service and that is where I use it.
What could be wrong?
This is my code inside the STARTER
(
B4X:
Sub Process_Globals
Dim JavaObject2 As JavaObject
End Sub
'.... init flp etc..
Private Sub flp_LocationChanged (Location1 As Location)
Try
'IsFake = JavaObject2.RunMethod("isMockLocationOn", Array(Location1))
IsMockLocationMio(Location1)
Catch
Log(LastException)
End Try
End Sub
public Sub IsMockLocationMio (Location1 As Location)
'ESTO NO FUNCIONA, pero isMockLocationOn sí, pero da error pues no detecta la función
'this not work, but isMockLocation is ok, but not work. funcion java are not detectec
' Dim p As Phone
' modGPStoy.IsFake= IIf(p.GetSettings("mock_location") = "0" ,False ,True)
JavaObject2.InitializeContext
modGPStoy.IsFake = JavaObject2.RunMethod("isMockLocationOn", Array(Location1))
End Sub
#If JAVA
import android.app.Service;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.provider.Settings;
import android.provider.Settings.Secure;
//import android.test.mock.MockContext;
import android.location.Location;
public boolean isMockLocationOn(Location location) {
Context context=this;
boolean isMock = false;
if (android.os.Build.VERSION.SDK_INT >= 18) {
isMock = location.isFromMockProvider();
return isMock;
} else {
if (Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION).equals("0"))
return false;
else {
return true;
}
}
}
#End If
Last edited: