Reputation: 1109
I want to get to the class GpsLocationProvider
on Android. I want to call a few methods of this class, like setMinTime()
.
Here is my code:
LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
GpsLocationProvider pr = (GpsLocationProvider)lm.getProvider(LocationManager.GPS_PROVIDER);
And the problem is GpsLocationProvider class is unresolved
. I know that it is located in com.android.internal.location.GpsLocationProvider
, but such import is unresolved as well, and import com.android.internal.*;
doesn't help to resolve ``GpsLocationProvider` too.
What does this mean?
Thank you for any tips.
EDIT: I know that I can change most of the LocationProvider
pararmeters through LocationManager
like LocationManager.requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener)
, but what I'm trying to do is a little hack. I want another programm to update gps coords more often than it does. That's why I cant use LocationManager
(that requires listener parameter), and want to set "global" gps params, that will affect another activity.
EDIT2: I tried with reflections as suggested by Reno.
LocationProvider provider = lm.getProvider(LocationManager.GPS_PROVIDER);
try {
Class classGpsProvider = Class.forName("com.android.internal.location.GpsLocationProvider");
classGpsProvider.cast(provider);
...
But unfortunately the call to lm.getProvider()
returns DummyLocationProvider
, and that one acts like a shadow for GpsLocationProvider
.
Upvotes: 1
Views: 1016
Reputation: 33792
You probably can't do that without reflection
You should be using the import android.location.*
Upvotes: 1