Skip to first unread message
Assigned to halatmi...@gmail.com by steve....@gmail.com

Arras Ate

unread,
Jul 15, 2014, 12:14:16 PM7/15/14
to mitappinv...@googlegroups.com
Hi! and thanks in advance (and sorry for my english)

I have created a little app to get and share my location. For testing purpose I have add a button to re-read the Location Sensor data.



I am unable to get my location data when I am using network location option (longitude 0.0 and latitude 0.0), but I get it if I set the ProviderName to gps and set ProviderLocked to true.

I have been looking for a reason why this happens in the Forum, but I am not sure other entries are exactly about this issue (https://groups.google.com/forum/#!category-topic/mitappinventortest/specific-programming-issue/S6hUmh4HV4A

I have read this tutorial too: http://appinventor.mit.edu/explore/ai2/location-sensor.html and I read there is a plan to write a future tutorial about this topic.

What am I missing?

Thanks!!

SteveJG

unread,
Jul 15, 2014, 2:27:40 PM7/15/14
to
To get your location with just network; set LocationSensor.ProviderName to     network

To get your location with just gps;  set LocationSensor.ProviderName to   gps
and then set LocationSensor.Provider.Locked after you set gps

TheLocatonSensor is very versatile on some devices.   If the gps can not get a satellite fix (it needs to 'find' and verify the data from at least three satellites), some devices will get the location automatically from  network.  They do that in various ways, the most common is that cell-phone towers are used to locate the Android.   In that case, the location information is of lesser accuracy than obtained from the gps receiver in the Android.  Well, usually.   The LocatonSensor and the gps may not be able to get a satellite fix because the Android is indoors, shielded by tall buildings or is located perhaps under a tree after a rain.

If you are getting the    No address available, but your device records correct latitude and longitude values, I believe what you are experiencing is a Google issue and perhaps not an AI2 issue.  http://developer.android.com/training/location/display-address.html    In some locations, Google maps just can not render an address because 1) there is no such address in the local Google Maps provider database, 2) the device is using cell tower info and it cannot get a triangulation or 3) other reasons.

If you attempt to get an address in downtown Los Angelous or in the middle of the Gobi dessert, you may get  no address available.   In LA, you can go outside, walk a block and see clear sky instead of buildings and may suddenly discover your device reports an address.

 I get a street location 90% of the time using the latest version of AI2, so I do not think it is an AI2 bug.

What are you missing?      If you lock provider and request qps, you will never get a network location.     If your device is in a location in which Google's system can not render an address, for whatever reason, you will get  no address available.  If you are in the middle of the Pacific Ocean, you will get no address available.  If you can not get an address, it is also possible  you may have previously denied permission for Google Maps to use your location (in your device settings).

Was this helpful?  Build your apk, load your device and try using different locations.   This might be difficult in some countries because the address might be blocked by the government, I think.

Future tutorial?    I've written a lot of them already about geolocation, mapping etc.  They just are not posted.   MIT does not have the time, staff etc to post and maintain tutorials at the moment.  They do not presently have a system working to consider what tutorials it wants posted.    Be aware, I can not even modify my own tutorial  (LocationSensor) as I have no access to the MIT system.

Regards,

Steve

Arras Ate

unread,
Jul 16, 2014, 6:02:53 AM7/16/14
to mitappinv...@googlegroups.com
Hi Steve, thank you for your answer!

As I understand, I should get longitude and latitude data whether the device is using network as if it is using GPS, and the app should work straight forward without any change...  Isn´t it?

My problem is that when the device tries to get the location from network, it doesn´t get any data (0.0 and 0.0). If I set ProviderLocked to work with GPS, it gets the location correctly (outdoor, of course)

I have build the app without lock the provider and I have try it in other devices, but I don´t get any data (Lon:0.0 and Lat:0.0) as they try to get location from network too.

I have try with other geolocation apps in the market, to test the device works ok, and I have get this:
"Where Am I?" Aspectiva LTD: I get the Longitude and the Latitude via network.
"Where Am I? GeoCode" Sivan Sundar : I don´t get the location data. (It seems it is build with app inventor)


Thank you!

Peep Prants

unread,
Jul 16, 2014, 6:18:13 AM7/16/14
to mitappinv...@googlegroups.com
Hi,

My experience is that if you use Android 4.4.* (Kit-Kat) then you have problem obtaining location throu network or WiFi. Older Androids works OK.

Arras Ate

unread,
Jul 16, 2014, 6:24:17 AM7/16/14
to mitappinv...@googlegroups.com
Hi Peep! Thank you!

I am using 4.1.2, I will check the other devices for the version.

SteveJG

unread,
Jul 16, 2014, 8:08:10 AM7/16/14
to mitappinv...@googlegroups.com
@Peep ..Versions of Android  of 4.4 have issues finding the location address?      Something to look at.   I use Android 4.2.2 and have no issues..I almost always get an address from  gps.    I do not have a phone networks so I can not test it.

@Arras / Peep.....     I suspect the inability to retrieve an address using network may be related to Settings and permissions on the device itself.
Google gives users an opportunity to"share your address with them,"   I suspect if you have not given them permission to know where your device is at, you get the no address available.

Please try this:   Go into your Android settings.   In the section called Personal >Location services, tell me how you have this set up.

Access to my location is turned ON .. it allows apps that have asked your permission to use your location information  

Location sources >  Use GPS satellites  (Allows apps to use GPS to pinpoint your location).   It is checked on my tablet.   Is it checked on your tablet?

Location sources > Use wireless networks (Location determined by Wi-Fi).   It is checked on my tablet.   Is it checked on your talet?

I do not have network capability on my tablet.   You guys MAY have something like Location sources> Use network.    or you may not?

I suspect that you may not have Use wireless networks checked?

Regards,
Steve.

Peep Prants

unread,
Jul 16, 2014, 8:42:27 AM7/16/14
to mitappinv...@googlegroups.com
Hi Steve, Thanks for answer!
Yes I know all those location settings and trying already different ones to get location trough mobilenetwork interior (3G-3,5G antennas or WiFi) but no success :(
I have LG G2 with Android 4.4.2 stock ROM. Same app (made by AI) and same phone before upgrade (Android 4.2.2 ) work like charm also in interior. That mean before upgrade I get location in same place (my working desk) without turning GPS on.
Also if I turn GPS on with full options (wifi, mobilenetworks) I can`t get location in interior with apps what I made with AI. Other apps like Google maps, Navionics etc. work like charm also in interior.

Peep Prants

unread,
Jul 16, 2014, 9:25:38 AM7/16/14
to mitappinv...@googlegroups.com

Android KitKat have new location mode (UI), which includes 3 options: High accuracy (GPS, Wi-Fi, and mobile network), Battery saving (Wi-Fi and mobile networks), and Device sensors only (GPS).


SteveJG

unread,
Jul 16, 2014, 10:04:17 AM7/16/14
to
Thanks for the image Peep.   I want a way to document this possible issue with AI2 rendering the reverse geocoding in the latest versions of Android.

I am sure the technical guys would want to solve this quickly.  To do that, we need some documentation of what you guys experience.
In that area, I can not help as I do not even have a 2.3 phone.

The issue, as I see it is 

1)  the Location.LocationSensor.CurrentAddress  seems to be failing on some devices, reporting a "No address available" message in Android 4.4 but NOT in 4.2 and lower.  You said you have code that runs fine on other devices but not on 4.4?   Did I understand that to mean the lower number devices render an address but 4.4 does not?

2) set  LocationSensor.Provider to network  might not be working in versions 4.4 +?      Possibly a phone network issue related to the type of phone ... GSM or whaterver network?

I found this:

Table 1. LocationProvider

LocationProviderDescription
networkUses the mobile network or WI-Fi to determine the best location. Might have a higher precision in closed rooms then GPS.
gpsUse the GPS receiver in the Android device to determine the best location via satellites. Usually better precision than network.
passiveAllows to participate in location of updates of other components to save energy

This might be an explanation of how you can use the energy saving stuff shown on your 4.4   .... instead of network,   try passive as the Provider?



3)  @ Peep... when you use Provider as gps, does your device render an address?     Be aware, this is sometimes difficult indoors so this has to be tested outside.

4)   Networks use several different methods to obtain CurrentAddress .  If the cell tower method is used, I am pretty certain a phone will render correctly the address, however, some of the latest technology networks use several different systems to report an address ... that might be the issue..

5)  I am going to flag this thread with the development team and the guy that wrote most of the LocatonSensor code, even though we can't throughly document this for him with an example ... need a simple Project and aia to demonstrate this behavior    and images from a 4.4 screen and a lower screen at the same outside location. Could you provide some documentation like this the technical team can work with?

I am working on this.

--Steve


Arras Ate

unread,
Jul 16, 2014, 10:12:08 AM7/16/14
to mitappinv...@googlegroups.com
Hi Steve!

Almost the same here that reported Peep... All settings and permissions seem to be OK, and I tried changing them and I get same result. As I wrote before other apps got location fine.

I send you the location part of my project as a aia for test if it helps.

The device I use is 4.1.2, I have tested in other devices (none of them 4.4) with same result.

Thanks both of you!!
ArrasateGPS.aia

SteveJG

unread,
Jul 16, 2014, 10:34:23 AM7/16/14
to mitappinv...@googlegroups.com
@ arras    Thank you.

I loaded this on my device.

Running the app in development on WIFI, on start, it gives a No Address Available message.
However, using the Location button it renders my address correctly  with both WIFi and gps enabled on the device.

If I physically disable gps and only allow the WIFI connection, the lat / lon changes a little bit, but I still get the correct address.

I have to find someone who can try this on first any phone and second a 4.4 phone.     Also, I need to build the apk and try it that way.
if the GPS is enabled on the device.  The icon disappears when I turn off the gps.    Why that behavior, I do not know, possibly because setting provider the way you do keeps checking for a gps?

Please do try this with your code, instead of setting  make the first block in Screen1.Initialize        set LocationSensor1.Provider to   gps   (put gps in a Text Block)  and try the app,
then  set LocationSensor1.Provider to   network
then set LocationSensor1.Provider to   passive

Again, I can not test using a phone network.

and tell me if you get a different result.    Thanks.

--Steve 

Arras Ate

unread,
Jul 16, 2014, 12:16:51 PM7/16/14
to mitappinv...@googlegroups.com
Hi! GREAT! I fixed it!

After reading your last post Steve I realized the error must be in the device. I was checking the LocationSensor.StatusChanged event, when I have found the A-GPS configuration in my device (it was really hidden, I have this device one year ago!) and it wasn´t enabled.

After enabling it and reboot the device, the network location is ok.

I was so sure it was enough with the WIFI networks setting enable, as Google apps got the location.

By the way, after this, I have test the app I mentioned in a previous post ("Where Am I? GeoCode" Sivan Sundar) and now it gets the location data via network. So perhaps AppInventor apps need A-GPS to be enabled? Or it was just my device hanged-up?

Thanks!!

SteveJG

unread,
Jul 16, 2014, 12:21:42 PM7/16/14
to mitappinv...@googlegroups.com
@Arras, Peep    I modified Arras' example aia to do some testing.  The aia is attached.  Could you guys try this and let me know what happens in your devices?   In your case Peep, on the Andrid4.4 where you see issues and also on a device that does not have the address issue..    Thanks.

Here is what I see:

When the Android has the following settings:

















The demo app shows this:


But if I use these settings:


I get the response I expect but perhaps you guys do not?

As you see, I get latitude and longitude data in all cases (be aware the data I get on network may be very diffferent because I have a WIFI only tablet)  and as expected, the gps gives the most accurate 
coordinates,  passive and network pretty much wrong, however in all cases I get the correct address ... yes I whited-out my address except for the last two digits.

Discussing the possible problem with the LocationSensor expert, he informs me  All app inventor does is send the lat/long to the google address server. 
.This implies to me that the local google address server is having issues at your locations (I do not know where you guys are).  

Provide some more input, and we might be able to resolve this.   Perusing the developer web pages that would normally flag something like this for Java developers, I can find no reason you guys consistently get No address available, other then the google servers at your locations have issues.     Try the example aia and PLEASE let me know what you get by manipulating the device's settings.

Thanks in advance.
 ..and Arras, sorry for modifying your code.

Regards,
Steve
AddressGeocode.aia

SteveJG

unread,
Jul 16, 2014, 12:30:18 PM7/16/14
to mitappinv...@googlegroups.com
Thanks Arras.   We got one of you working properly.   I am very glad you got your other Project working too.

@Peep ...  are you OK yet too?   Let me know what happens when you test the aia I sent.   Perhaps you have the same issue after the upgrade.   If not, I will continue to work with you and MIT to find a reason and a solution for the behavior you see.

@ Arras   yes, the GPS has to be activated.      set Location.Sensor.Enabled to  true   is supposed to enable the gps automatically and actually the just by placing the Location.Sensor Blocks in your environment is supposed  to get an automatic response from the GPS (unless it is not manually turned off) and through network).   I am not certain that works will all devices,.

Regards,
Steve

Arras Ate

unread,
Jul 16, 2014, 12:54:17 PM7/16/14
to mitappinv...@googlegroups.com
Hi Steve. I´ve testing your aia (no problem for change mine! Thank you for testing!!) and now I get the same as you.

Perhaps this is the trick: now when I try to enable the "WLAN & mobile network location" I get a warning I didn´t get before (Attached image) If I agree, the WLAN location is enabled, and if I disagree the WLAN location remains disabled. Really: before the restart of today in all my tests I haven´t get this warning. If I disagree, the app doesn´t locate me, as expected, else, if I agree the app works like a charm.

As you say, may be this issue has to see with a Google server issue, and with the Location consent.

Thank you very much!
Screenshot.png

Peep Prants

unread,
Jul 17, 2014, 2:46:26 AM7/17/14
to
Hi Steve, Thanks for testing app and sorry about test delay (was busy evening)!
Test was helpful, I test only interior in my working desk, phone LG G2 and Android KitKat 4.4.2
By pressing order!
TEST ONE (GPS ->ON, mobile DATA ->ON):
1. Black - NO
2. Red - NO
3. Blue - YES
4. Green - YES
5. Black - YES
6. Red - YES
TEST TWO (GPS ->ON, mobile DATA ->ON, WiFi->ON):
1. Black - NO
2. Red - NO
3. Blue - YES
4. Green - YES
5. Black - YES
6. Red - YES
Same result but accuracy is more correct.
TEST Three (GPS ->ON, mobile DATA ->ON, WiFi->ON):
1. Green - NO
2. black - NO
3. Blue - YES
4. Black - YES
5. Red - YES

My opinion: In KitKat Android AI not try get location automatically throu network first (In older Android it work). It work only if declared ProviderName ->network but then accuracy is not so perfect 
Maybe some workround using timer.







Arras Ate

unread,
Jul 17, 2014, 5:11:02 AM7/17/14
to mitappinv...@googlegroups.com
Hi guys! I solved my issue, but I see you´re working about 4.4... Will you mark this one as finished when you finish? Do you think is better open a new one? As you want...  Thanks a lot!!

Peep Prants

unread,
Jul 17, 2014, 7:38:28 AM7/17/14
to mitappinv...@googlegroups.com
Hi Steve, what you think, is correct to declare all providers in screen load?

Like this?


SteveJG

unread,
Jul 17, 2014, 7:51:53 AM7/17/14
to mitappinv...@googlegroups.com
@Arras / Peep

Thanks for using the test.    Yes, I will mark this complete.   It appears there may be an issue with 4.4 but it might be with the hardware or how the networks work.

@Peep   ... 
'get location automatically through network first (In older Android it work). It work only if declared ProviderName ->network but then accuracy is not so perfect '

I think your analysis is basically correct.    You get the performance you get on kitkat and the device probably because of how the device selects whether to use gps/network/passive.  The hiearchy probably is determined by 1) your device   or 2) kitkat   and I do not know which.   Ai2 only can respond to getting a latitude and longitude ..if it does not capture a latitude/longitude, it can NOT provide an address.

When one does NOT declare   gps , passive  or network, I believe the phone uses the hierarchy it is programmed with.        

Where is your BEST location rendering?
That is pretty easy....  GPS is almost always going to be the best, provided the GPS can get the results of more than three satellite fixes.
Now, I am aware there is some new technology that actually allows network (in some systems) to IMPROVE the accuracy reported...a combination of network and gps ...I do not know how that works, only that it is possible.
Network, by it self is normally much worse than GPS  for providing an exact location...except when the Android is in a building, where the network will frequently provide a better 'location'.
Passive, again, not sure exactly what happens here.

The simplest networks  uses cell tower triangulation by measuring signal arrival times and comparing...I know that other systems are in use that are more accurate.

You tested inside.   I imagine you MIGHT get a slightly different result if you take your devices outside so the GPS will dominate the hiearchy.   Remember, if GPS can not get a fix, the system will revert to network or perhaps passive.

...and you just posted another note..

--Steve



SteveJG

unread,
Jul 17, 2014, 8:03:27 AM7/17/14
to
@ Peep...   an apparently great idea, you will not know unless you test it .     No phone here, so I can not.

I suspect what will happen here is this code will set Provider to passive.     AI2 commands are carried out sequentially, so first  network will be set, then Provider will change to gps, then to passive and stay at 
Passive.    You did not set Provider.Locked to True    , so I am not sure if the kitkat device will stay in passive or revert to gps.    Test it, if you see the GPS icon flashing on you kitkat, then GPS is attempting to get a satellite fix .... you need to do these tests outside... at your desk is not going to be an accurate test.

Do you want to have some fun?     Download the Source File (.aia) for GPS Accuracy Logger            from the LocationSensor tutorial http://appinventor.mit.edu/explore/ai2/location-sensor.html.
Then look at Accuracy as described, changing the Provider to GPS, network , passive    or not declaring any and letting the device determine where it wants to be.  Build the apk , install it and put it on your device.   You will have to add buttons to change Provider between the various modes.   That will allow you to see how the precision of your location fix, whether satellite or network changes.  Gosh, I wish I could try that.

@Arras / Peep .... if you want to continue this discussion, just start another thread    .... kitkat and Google Geocoding    perhaps.

...another edit ... from the image you sent, it appears I need to find a description of the API for kitkat geolocation, If there is one ...there might be an explanation about what developers need to do to get the desired response.         I am not sure how to provide Provider instructions to access this stuff:





Regards,
Steve

Taifun

unread,
Jul 17, 2014, 10:03:06 AM7/17/14
to mitappinv...@googlegroups.com
@Peep: something like this does not make sense, the last provider name will win in this case



Taifun

SteveJG

unread,
Jul 17, 2014, 6:02:05 PM7/17/14
to mitappinv...@googlegroups.com
@Peep       I think you can do this:

StatusChanged(text provider, text status)

Called when the status of the service provider changes.


I do not have a phone so I have not tested how this event could be used. Code like this should be possible in the StatusChanged block:

If provider = gps and status = TEMPORARILY_UNAVAILABLE then

LocationSensor1.Enabled = False

LocationSensor1.Enabled = True


or use StatusChanged to report LocationSensor1.Provider.


That would allow you to see which of the automatic methods is in use?


Regards,

Steve


Reply all
Reply to author
Forward
0 new messages