Skip to first unread message

Terry Chae

unread,
Jul 27, 2015, 8:36:27 AM7/27/15
to MIT App Inventor Forum
My phone is galaxy s6 edge and
gps location latitude and longitude returning 0.

Any solutions?

SteveJG

unread,
Jul 27, 2015, 8:47:06 AM7/27/15
to MIT App Inventor Forum, huny...@gmail.com
Zeros indicate that either the GPS is not turned on  or the the GPS cannot obtain a satellite fix or it has not yet obtained a satellite fix. A zero is an indication the GPS is not enabled or a fix is not yet ready or you are located on the Prime Meridian and the equator.

Is the GPS icon flashing in the top left of your Android screen?  Do you see the icon? If there is no icon, then the GPS is turned off.  Simply enable it on the device.
If you are developing in a room without windows, the device possibly cannot get a satellite fix.  Have you read the article about how the GPS works in the LocationSensor Tutorial    http://appinventor.mit.edu/explore/ai2/location-sensor.html    ?  There is a very simple LocationSensor tutorial here:  

Where Am I? … a very simple LocationSensor Tutorial


There could be issues with your code; if you do not post screen capture images of your blocks, we can only guess Terry.

Regards,
Steve

Terry Chae

unread,
Jul 27, 2015, 8:56:59 AM7/27/15
to MIT App Inventor Forum, huny...@gmail.com
The GPS icon is flashing on status bar. And I enabled GPS on my phone.

This is my blocks.



SteveJG

unread,
Jul 27, 2015, 9:14:32 AM7/27/15
to MIT App Inventor Forum, huny...@gmail.com
Kamsameda Terry for the blocks.  Where is your LocationSensor.LocationChanged block?  The green GPS.Location blocks are insufficient, programmed like this, those values will always be 0,0

-- Steve

Terry Chae

unread,
Jul 27, 2015, 9:29:09 AM7/27/15
to MIT App Inventor Forum, steve....@gmail.com
Thank you for your Korean words :)

Then what should I put for LocationChanged block?
I have no LocationChanged block.

SteveJG

unread,
Jul 27, 2015, 9:50:32 AM7/27/15
to MIT App Inventor Forum, huny...@gmail.com
You need the LocationSensor LocationChanged block object as shown below.  The LS is in the Sensor drawer.  You need two global variables... try myLatitude and my Longitude. Initially set them to 0.





Where you have your green latitude and longitude  blocks, substitute the appropriate orange variable blocks shown here.  This might get you app working...it is possible you might need a few more blocks... have you read the LocationSensor tutorial?  With the default settings the LS will attempt to update once a minute.  You really need to do read about what is possible in the tutorial and here   http://ai2.appinventor.mit.edu/reference/components/sensors.html#LocationSensor.

Does this work?

Regards,
Steve

Terry Chae

unread,
Jul 27, 2015, 9:56:38 AM7/27/15
to MIT App Inventor Forum, steve....@gmail.com
Thank you for your advice, Steve.
I appreciate with your kindness.

Sincerely,
Terry

Terry Chae

unread,
Jul 27, 2015, 12:14:43 PM7/27/15
to mitappinv...@googlegroups.com, huny...@gmail.com
Steve,

I set LocationChanged block, but it doesn't work. It returns 0 again. And GPS icon on status bar does not flashes. Just showing stoped icon.

This is my blocks

Thank you again!




SteveJG

unread,
Jul 27, 2015, 12:57:37 PM7/27/15
to MIT App Inventor Forum, huny...@gmail.com

Recall, I said to get rid of the green Latitude and Longitude blocks? ...You forgot.  Just use the orange blocks in their place.

Working now?

Terry Chae

unread,
Jul 27, 2015, 9:47:54 PM7/27/15
to MIT App Inventor Forum, steve....@gmail.com
Hmm... Still not working..

GPS icon is on status bar correctly.
I set Latitude Text, Longitude Text (Green block) to get Global myLatitude, get Global myLongitude (Orange block).

Sorry Steve.

SteveJG

unread,
Jul 27, 2015, 11:09:15 PM7/27/15
to MIT App Inventor Forum, huny...@gmail.com
OK ...you have to debug one part at a time.

The following aia works with the LocationSensor and GPS.    Just load it and run on your device.   It runs automatically on app start...it may take 20 to 30 seconds to display lat and lon.

"Still not working" ... the texting or the gps? For the gps, the SimpleGPS should work.

SimpleGPS.aia

Terry Chae

unread,
Jul 28, 2015, 9:53:46 PM7/28/15
to mitappinv...@googlegroups.com, steve....@gmail.com
It finally works!!! Thanks:)

Regard,
Terry

SteveJG

unread,
Jul 28, 2015, 10:01:16 PM7/28/15
to MIT App Inventor Forum, huny...@gmail.com
What is not working Terry?   Are you testing this on a device in a building not near windows?  The GPS may not be able to get a satellite fix. Go outside perhaps.
The code snippet works fine on my Samsung and also on my phone.

--Steve
Reply all
Reply to author
Forward
0 new messages