Hello everyone , i try to do some gps based app but when i run the program it returns only 0 as the coordinates ; i tried to export to my android device but with no avail , i used the "when coordinates change" inside blocks , does anyone have a clue of what's going on ? please ! and thanks in advance
Have you granted location permissions?
enable GPS and test outside to get a good GPS signal
Taifun
Welcome @zipzap94
The 0's are the default LocationSensor coordinates 0,0 . These represent a location in the South Atlantic Ocean off the coast of Africa and are displayed until the LocationSensor receives a LocationChanged event.
What is happening is you are either:
-
not providing sufficient time for the gps receiver hardware to determine where the device is located. The device does not know where it is until it receives a satellite fix through the gps and triggers a locationchanged event.
-
your device doe not have a gps receiver. Some tablets do not.
-
your device Location settings are not turned on (essentially Patryk's comment). The LocationSensor does not need to have permissions set by code. When you use the component, the permissions exist but you must also have the system Location set to allow use of your location.
-
or as Taifun mentioned, you cannot get a satellite fix because your device cannot hear the satellite radio signals because the construction of your building interferes and mutes the signal strength.
Have you done the tutorial Using the Location Sensor and loaded the example aia Projects? Try those Projects and tell us what happens please. Do you see your location geocoordinates displayed in either example?
Re and thank you for the help , i read your reply and tried the "using the location sensor" program that you provided , and i get no number for the coordinates BUT when i click on the "toggle provider" button it does work !! i have coordinates etc .. my problem now is that i need to click that button in order to run the programm normally , do you guys have any clue why i need to click on the "toggle provider" button ? (any help is welcome)
I also noticed that when i click on the "capabilities" i have no lat/lon nad no altitude and when i click toggle provider and click again on the same button it does have lat/lon and altitude
please help me
It is time for you to share your code.
Perhaps.
- are you using an emulator"
- you might be using a tablet that does not have gps hardware. If you are in that situation, the locationsensor can determine a location without using a gps receiver. When you toggle, you are probably using WIFI or network cell towers (see the tutorial for an explanation)
You see a screen like this:
.You don't have lat/lon and altitude when the app is is used to test. This means the device has issues. When you click toggle provider and click again on the same button it does have lat/lon and altitude because your changed provider is passive or network and is providing location information but not from a gps receiver. Which provider allows you to display latitude and longitude? It should display in Provider Name: and is probably passive.
I suspect when you run the app you do not see gps listed in the List of Providers (circled in blue) that are possible with your device. Is that true? If gps is absent from the listing, your device is probably a tablet and does not have gps hardware. Not all devices have gps hardware. This means to determine a location using your device using the LocationSensor, you have to force the provider.
i suspect that my device is badly configured but i have my waze and other apps using the gps sensors working . my device is a cellphone huawei p30 so it really should work . I am not using an emulator i run the program on the cellphone with the apk file installed .
Would you have a clue on how i could test my hardware gps so as to see where the problem comes from ? Maybe that the matter is not app inventor related after all ... btw i dont have a "code" my code is minimal i just used the basic gps functions . Help !!
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.
To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.
Taifun
Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.
If you really want Help, you might answer questions that might help us resolve your Huawei issue. So, please tell us
The information displays on the tutorial app. We would like to know what Providers are displayed when you test. You asked " how i could test my hardware gps"
The Location Sensor Test is designed to test the capabilities of your device.
You were also asked "It is time for you to share your code."; Taifun asked again. No one can help you if you keep telling us what should happen without sharing the code that seems not to work and answering questions that should help us help you.
Your device's dual-band A-GPS, GLONASS, BDS, GALILEO, QZSS might be the issue. The MIT LocationSensor might not be handling this advance technology correctly.
Blockquote It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.
this is the toggle button that fizzles with me
Blockquote Which provider allows you to display latitude and longitude? It should display in Provider Name: and is probably passive.
indeed the provider that works is called gps passive gps network , provider name is : network / my code is the "location sensor test"
the weird thing once more is that my device returns gps coordinates with waze and google maps , so i'm confused that this app is returning nothing , i tried to shut and reset the parameters of the gps but with no avail . Am i the only person that has this kind of problem ?? my device is a good modern phone ...
your screenshot is useless to answer your questions
probably yes
and without some reasonable relevant blocks there is not much anyone can do except of guessing....
Taifun
The providers that are available on your phone are gps passive gps network, The Provider Name that works for you is network.
This tells me your phone is using the network cell towers to determine coordinates. For some reason, gps is not working. I do not know why? I speculated in an earlier post.
As Taifun speculated, perhaps yes. Your device may be modern but the LocationSensor might not be able to handle dual gps phones. The code for the LocationSensor was written before such phones were available (in about 2013)
Here is a different testing app you could try. When you get it, run the program and let me know what you see on the display. You can test gps, passive and network.
SimpleGPSTester.aia (6.9 KB)
ok i did run your app and i get no "test now gps" answer , no "test now passive" but "test now network" returns coordinates , ok this is coming from my phone , the funny thing is that when i use gps for my car it returns accurate coordinates and i didnt tweak anything on the phone , i may go to huawei forums to sort this out , thanks anyway
I am having the same issue, the same app on android 12 works fine but on android 7 it only returns 0
What app are you talking about David that 'works' on Android 12 but not Android 7?
Most developers experience issues where lower Androids work but 12 does not. Frequently the new 'fused' Provider is part of the problem and LOCATION permissions.
This discussion might be what you are talking about GPS with Android 12 .
All anyone can do is guess why you see the behavior you get without more information, . There are dozens of reasons why a device only returns a location of 0,0 (the default location when Provider does not return a location). Reasons for failure to return location coordinates may be related to LocationSensor settings, Android System Settings, sensitivity of the gps hardware in the device (not testing outside), wrong Provider settings, trying to update the satellite fix too frequently, not waiting long enough to get a response from the gps receiver etc.
True and in fact I made sure by using different techniques and combinations of permission to make the gps work on android 12. After many weeks I made it run smoothly by using an extension...
Unfortunately, some parts of the inbuilt command block work on android 7 and not on 12 and vice versa and so I had to use the right combination to make it work and try to make it work on both versions. Now the command in question is the Locationsensor.LatitudeFromAddress and same for Longitude. I am using a text box to make the entry, put it in a variable in order to obtain an address. Now on Android 12 it works fine but on 7 it ALWAYS returns 0 so not location found.
I tried using the KIO Location extension which works fine on both versions but with the KIO if the location is not found it returns nothing which creates a run time error in the app of android 7
As I recall, the KIO extension does not work properly for Android less than about 8.1 (I might misremember); inability to work with Android 7 might be your issue. "If the location is not found it returns nothing", then you might be able to code around it. I don't think these two are equivalent
but they might be; contact Juan Antonio perhaps?Add a real LocationSensor to use if Android is 7 etc. perhaps? It is possible to use both components simultaneously in the same app.