hi! im trying to make an app for pollution measurement using the openweather API (pollution api) and i'm trying to use the gps sensor of my phone in order to place a marker where i am in a map and display the amount of co2,no2,O3 etc...but i'm struggling to do so
can someone help me ?
i'd like to have the same result as Elham_Ali
here is a screenshot of the code and the app look atm:
OK. There are probably better ways but this code example works with the openweather API. Use a dictionary or an extension to parse the air quality json. This example uses a dictionary, a LocationSensor etc.
yeah,the code looks like its working ,but i dont know how you placed all the labels
can you show me where you placed all of them please?
oh yeah and i got a "select list item:list index too large,attempt to get item number 1 of a list of lengh 0: []"
Perhaps you need to uncheck the Clock TimerAlwaysFires and TImerEnabled on the Designer Properties screen. If your problem persists, post an image of your Blocks; you may have not copied everything correctly. It could be something else like not having a satellite fix yet when you press the Get Air Quality Button1.
Press it again perhaps. It will do nothing until the gps gets a satellite fix. Your cell phone has to know where it is located. The quality is a number and a quality. Like 1 Good .
You did not input your openweather api password correctly. Check for a trailing space.
Your device system is not set to use gps
A required property is not set on the Designer. Which one, I don't know.
You are not connected to WIFI or Data
You are not waiting long enough to achieve a satellite fix before pressing the button. Wait at least 30 to seconds the first time you press it.
Something else. Try this aia, but 1st modify the code in the Web1 url so your openmap api password is used. I have disabled mine. AirQuality.aia (6.8 KB) The app does not work without the required free password from openmap.
what version of Android are you using. At least for Android 8.1 and lower, the Permission Block ask is NOT needed. In fact, coding it could be causing your latest error by including it. Also there would be no reason to request Permission MockLocation in any case.
The aia also works on an Android 11 cell phone. Unless you are Android 12, there almost certainly isn't any reason to modify the aia code.
Did you try the attached aia I provided and set up your openmap api password?
so,i tried going outside with my phone (android 7) but still nothing,parameters are ok with location permissions
i tested multiple locations but still nothing
i'm now going to try with the .aia @SteveJG gave me,but i dont know how to setup my "open api password" are you speaking of the api key?
ty
oh yeah and i removed every .askforpermission except the fine.location one
yes. Download the aia; replace the api key with yours, then run the app. Be aware you may have to press the Button several times (until your gps achieves a satellite fix) and the wait between presses may need to be 30 to 60 seconds. Good luck.
Just test the aia. Do not ask for permission. It should not be required.
yay! it works! i think my code wasnt working because of "call map1 .PanTo" missing for some reason lol
thank you for helping me out!
i'll set your message that contain the .aia as solution, is it okay for you?