Location Sensor not working

2,117 views
Skip to first unread message

Dwight Jessup

unread,
Oct 21, 2015, 1:34:30 PM10/21/15
to MIT App Inventor Forum
I am teaching my students the "Where Is North" program and programming the orientation sensor.  A few of my students cannot get the Location Senor to work.  This is not a programming issue - this is a device/hardware issue.  I have connected other android devices to App Inventor and their program works fine on other devices.  But as soon as we connect their device back up, we cannot get any location readings that should be displayed.  I have gone through all of the operating system settings to turn on the "Location" settings, verifying a device that works to the devices that don't.  All settings appear to be equal between the devices.

On the devices that don't work with the "Where Is North" program, I have launched Google Maps and it appears that it is finding the location in this app.  But nothing works in the app they created on their device and yet their program does work on other devices.  Further research is leading me to tell the students that they may need to do a factory reset.  I am not going to push them to that unless I can determine that it will 100% solve their problem.

These students are working on an ASUS 7" tablet running Android KitKat.  I tried to see if their device would accept the next release of Android but it is saying that their operating system is up to date.  I have run out of ideas and things to check.  We have other students (and myself) that have ASUS 7" tablets they work just fine.

Does anyone else have a possible solution or things to check as to why the location sensor does not appear to be working on these devices.

Taifun

unread,
Oct 21, 2015, 1:44:11 PM10/21/15
to MIT App Inventor Forum
sometimes you do not get a good GPS signal inside buildings...
in this case it helps to go to the window or to go outside...
it takes a few seconds until the location sensor provides a location...
Taifun

Hossein Amerkashi

unread,
Oct 21, 2015, 1:57:15 PM10/21/15
to MIT App Inventor Forum
What you can do is to have a timer that every 30 seconds or so performs 
locationSensor.Enabled(true) -- this will cause refreshing for gps.

Give it a try and hope it helps.

_____________________________
Hossein Amerkashi



SteveJG

unread,
Oct 21, 2015, 3:03:45 PM10/21/15
to MIT App Inventor Forum
The LocationSensor works in a number of ways depending on how the program you use is coded.   Not familiar with Where is North, however, that appears to be an app that requires the Orientation Sensor.

Some Tablets, depending on the model, do not have a GPS receiver; some do not have an orientation sensor.   

LocationSensor will work without a GPS receiver, as long as it is connected to WIFI or a network.

As Taifun mentioned, a GPS might not provide reliable readings in a room away from windows depending on the sensitivity of the GPS receiver in the device.

Regarding the Orientation Sensor .... the sensor does NOT necessarily point to geomagnetic North.    It points to the nearest strongest magnetic field.  This could be you computer monitor, a running electric fan or motor or a large metal desk.  The only sure way to test an app like this is outside.

Have you read and attempted the two Projects in the Location Sensor tutorial?     Exploring with Location Sensor in AI2

The location sensor object is used to communicate with the global positioning satellite receiver (GPS) in your phone/tablet. When the LocationSensor communicates with the built-in GPS receiver, the GPS can determine the location of your device.  The sensor can also work with network/wifi location services.  Finding a location using the network uses very different techniques to determine a location. Location means, the device's present latitude and longitude or it can mean your street address.


Confirm, by using the Tablet's model number and googling for its specifications that the tablets in question do indeed have both a GPS receiver and an Orientation Sensor.   

Also, if the student's are each coding their own versions of the tutorial, some of them might have left out a step.   Without a copy of the code, it is not really possible to debug the issue more than this.


Please do check:    is there a GPS?    is there an Orientation sensor?     Is each student's code correct?  ..and please do read the Location Sensor tutorial to get a better understanding on how the Locatiion Sensor works.


Regards,

Steve


Dwight Jessup

unread,
Oct 22, 2015, 10:38:03 AM10/22/15
to MIT App Inventor Forum
Steve,

As I stated in my original post - this is NOT a programming issue.  We have connected other tablet devices to the code of the person whose tablet is not working and the code works fine.

The specs for the tablet state that it has a GPS and as I stated in my original post, I verified this by using Google Maps and it finds us with no problems - even in the building we are working in.

Before I post to this forum, I usually have done a lot of research, tried many different solutions, and discussed this with many other technical resources.  I personally have worked over 25 years as a technical consultant for many leading technology companies (and on tech support lines) before semi-retiring to teach what I have learned.  As I explained in my original post, we did everything you are suggesting.

I am looking for the unusual solution beyond what I have already researched and tried.  We are attempting Hossein's recommendation to see if that works.  I will let you know.

Ghica

unread,
Oct 22, 2015, 12:15:13 PM10/22/15
to MIT App Inventor Forum
Don't be defensive! AI2 is sometimes really difficult for experienced developers like us!

Maybe a tip that helps. You should not use the GPS before it has a fix, otherwise it seems that it is not there.
The way to wait for a fix is to use: when LocationSensor1.LocationChanged (I usually have a label with red text that turns green when the fix is found).
This can also help to figure out whether the GPS works with AI2 on the particular phones that have problems.

Cheers, Ghica.

Dwight Jessup

unread,
Oct 22, 2015, 12:39:42 PM10/22/15
to MIT App Inventor Forum
Ghica,

Thank you for your suggestion.  We will give this a try as well.

I am not being defensive - it is more like frustration when people ask you to do something that you have already stated to have tried and it did not work.  I spend a lot of time documenting what I have done and then they don't even read my post to understand.  They just begin throwing suggestion out there with no reason.

It is even more difficult to troubleshoot when you have the same devices and the code works on one device and not another.  That is why I tried to determine if it was a hardware issue by launching Google Maps to test the location sensor - thinking maybe the location sensor on the device went bad.  Since Google Maps works, I should assume that the location sensor is working - maybe not?

I am not sure if this problem will ever have a solution, but I was just throwing it out there to see if anyone else has run into this with the tablet we are using.

Thank again.

SteveJG

unread,
Oct 22, 2015, 1:06:25 PM10/22/15
to mitappinv...@googlegroups.com
"it was a hardware issue by launching Google Maps to test the location sensor - thinking maybe the location sensor on the device went bad.  Since Google Maps works, I should assume that the location sensor is working - maybe not?"    Definitely not Dwight.          The LS will use the network or WIFI and Google Locations services if it cannot find a GPS.  The LocationSensor component is in the software and polls the Android to find a location using either the GPS or WIFI or network  using several different methods hidden from the user.  There is no location sensor in the Device ... there might be a GPS receiver.  An Android can provide location information without a GPS ...as described in the LS tutorial.

The LocationSensor tutorial describes how to set the app to work ONLY with the GPS        set the   Provider to gps and then  lock it (ProviderLocked = true), then you can run your "test" to see if the GPS is working...there are also 

Are you using this example  https://docs.google.com/document/d/1YMlP-Dh2NCasMIv-8ono8CJwHeeUYihNLqjsKExWf1Q/edit   or perhaps this one http://www.cs.trincoll.edu/~ram/cpsc110/tutorials/whereisnorth/hw-whereisnorth.html   ?      If so, part of the issue is possibly how the LS is set up in the example and the very unusual coding in the LocationChanged block.  It takes 20 or more seconds for the GPS to initialize and find a satellite fix; subsequent fixes could take less.  That example suggests polling every ten seconds ... polling that frequently is not prudent as as described in the LS tutorial.  Since you read the tutorial you are probably aware of that.

You did not post am image of the blocks you are using and are convinced the issue is not the code.  Well, we are not because we cannot see the code you used.  You may have a broken gps in a device, the Android Location Settings within the device might not be set properly ...


Rest assured, everyone's posts are read ... just because a user discounts an issue in the code does not mean that is not the issue.    You are not the only user to be sure the issue is not in the programming and has discovered otherwise.   Code is a possibility...other issues were mentioned.      and another possibility are the settings   shown above.

..and an edit 25 minutes after this was written.... can you and your students    see   the    small icon that looks like a spider with four legs at the top of your Android screen.  When that is flashing, it means the GPS is seeking a satellite fix.   When it is solid it means it has a fix with an exception, if the developer keeps asking for a fix, the icon will stay on the screen while the GPS is having a hardware heart attack.        If you do not ever see the white circle with four spokes , the GPS is not working, does not exist or .....










Dwight Jessup

unread,
Oct 22, 2015, 1:43:27 PM10/22/15
to MIT App Inventor Forum
My apologies.  I assumed that by posting the type of device we were working on you would have known that we are Wifi location dependent.  I should have clarified that in the beginning that ASUS tablets devices we are using only work on location based on Wifi and does not have a GPS.  When I talk about the LS, I am referring to the code in App Inventor not the device.  As you stated the interface is hidden from the user.

We have 23 of the same devices.  21 of them work on this code and two don't.  Do you really think it is still the code?

The image you sent me of the GPS locations is not on the settings for our devices (looking in the "Location" area of the settings).  Is it elsewhere in the settings? - we cannot find it.  Is it not there because we do not use GPS only Wifi?  That would be my guess.  Let us know where we can find it.

SteveJG

unread,
Oct 22, 2015, 2:04:56 PM10/22/15
to MIT App Inventor Forum
Since your Asus tablet does not have GPS, it will not have a GPS 'box' as shown in the image Dwight.  You should have a screen in the Android Settings that says something about Location.  Make sure the switch is set to allow Access to my Location.    I would take one of the 'good' devices and compare its Settings with the settings on the two that do not seem to be working...are the switches identical?

I would create an apk and load it on one of the 21 and see if it runs.   Then I would try the same sourced apk on one of the two.  Does the app work on the misbehaving gadgets?  If it does and assuming it has the same settings, the problem is probably with one of the code sets.    It is not really clear to us whether each student has coded his/her own Project or not.  We do not know unless we are told.

The location techniques in Android devices using only WIFI only on a model of a device should all perform identically, unless a setting is different in the Settings or the code run is different.   I am not aware of anything that should make the two black sheep run differently so do the above simple experiments.

Since you said Google Maps works on all 23, my guess is a student made a coding error..I do not know.  If the example you used is one of the ones I mentioned, and you followed these instructions:   In the template we have changed the Location Sensor’s default TimeInterval from 60,000 milliseconds (every minute) to 10,000 milliseconds (every 10 seconds).  That means that the phone will check for a location change every 10 seconds ; set the TimeInterval back to 60000 ms and the app might start working.



--Steve

Dwight Jessup

unread,
Oct 22, 2015, 2:36:48 PM10/22/15
to MIT App Inventor Forum
Like I said in my original post - we have compared settings and we have wifi/USB connected on all of the devices to the same code - 21 work - 2 don't.  There is not much to the location setting on these devices.  I was hoping to see if anyone knew of any other setting that may need to be checked that we may have overlooked.

It appears this is what we call in the tech world - an anomaly - and we may never know how to fix this, but I am tenacious and will try my best to find a solution like I have done many times before.

SteveJG

unread,
Oct 22, 2015, 2:45:58 PM10/22/15
to MIT App Inventor Forum
OK... but did you actually load the same apk on one of the 21 and again on one of the black sheep and test?    Why  do I ask?   because us said "we have wifi/USB connected on all of the devices to the same code "   and I do not know what that means.  I suspect it means you are running the app using Companion.  Do all the devices have version 2.35 of Companion installed?
Reply all
Reply to author
Forward
0 new messages