0

I have found different codes that explain how to use the GPSTracker class called from the MainActivity. In fact I was able to successfully follow the one from HERE an make it work for me.

Now my problem is that I want to call the same GPSTracker, not from the MainActivity class, but from a class one level deeper than MainActivity class.

So, 'MainActivity' calls function 'X' from second level class 'func'. Then, from class 'func' I am calling the constructor GPSTracker gps = new GPSTracker(func.this);. Then I obviously have the GPSTracker included in my eclipse project.

Up to this point eclipse doesn't mark any error in the code, but using the debugger tool I found that gps.canGetLocation() is always false. I want to point out that I declare

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

in the manifest file. I also want to point out that of course I have wifi and gps enabled.

Any help deeply appreciated.

Community
  • 1
  • 1
kapella98
  • 11
  • 3
  • If you're using GPS, do you have a location lock? Is the little GPS symbol appearing in your notification bar, and is it solid or flashing? If flashing, it means you don't have a GPS connection yet (GPS frequently will not work indoors). If not appearing, you aren't requesting GPS updates. – Gabe Sechan Jul 02 '14 at 02:49
  • Additional comment- that GPSTracker class has some major flaws that if you don't understand the LocationManager API will bite you severely on your ass. In particular, canGetLocation returning true does not mean that you actually have a location or that it isn't a stale location. I wouldn't advise using it. – Gabe Sechan Jul 02 '14 at 02:56
  • Hello Gabe Sechan. Yes, I forgot to mention the GPS location was locked. Besides this GPSTracker class seems to also work with WIFI which I had enabled. Further more, It works when I use it directly from MainActivity class, but when I call it from a second level deeper it doesn't work any more. – kapella98 Jul 03 '14 at 04:52

0 Answers0