How do you get the city and country only?
Example: Tokyo, Japan
Sorry for the inconvenience!
How do you get the city and country only?
Example: Tokyo, Japan
Sorry for the inconvenience!
And I would also like to know how to make the time update on its own.
I did this and I want the seconds. minutes and hours to update on its own. How
Sorry to disappoint you developers, the routine posted by @ABG only provides the time zone your device is located in. The routine does NOT provide the city it is located in.
For instance, it indicates id="America/Chicago" on my devices. I am located in Texas.
The only way using Blocks to get this information is to use the LocationSensor. This tutorial
shows you a way to get the city and country of the current location.
Use a Clock to get the time and date.
Try it.
Update time on its own? Use your blocks with a label and place them in the Clock.Timer event handler. The default interval is 1 second (1000ms); change the display interval to anything you find convenient.
Did this work for you?
First of all, thanks for your help.
Next would it be a bother to post pictures of the relevsnt blocks>
Thanks
I suppose, IP address extension. Luckily, I was just about to post this question in the community to see if there are better options while your post showed up of nowhere .
See the parameters.
If you want time or date, use a Weather Mate extension.
See this example of a digital clock
https://gallery-appinventor-mit-edu.ezproxy.canberra.edu.au/?galleryid=02d4b962-34b4-4c5e-8fdf-f17cc87dde23
Maybe you can use an NTP server.
This is a Blocks only solution. It does not require an extension and gets the time, date, city and country now
The Clock updates every 30 seconds. The LocationSensor initially requires about 30 to 60 seconds for the first response; later updates occur for whatever time interval is set.
The values set work in the USA, you might require some modification depending on what CurrentAddress returns in your location
Is this what you wanted to know?
However, device time can be changed by user.
Yes, it is true. The original question was
and that can be done with Blocks. Extensions can also provide useful information. The method a developer uses to capture this information depends on why he/she requires the info.
It is a shame the Location Sensor (manager) doesn't provide a property of the time fix:
https://developer.android.com/reference/android/location/Location#getTime()
Nice little job for a student....
Yes but what he'll do with wrong information.
What if you replace device time with online time obtained from DateTools? That'll be better and more accurate.
I don't expect the Clock time options to be a problem Sunny for most users. The Clock tools are more than adequate for most purposes to determine date and time. If someone has concerns the date/time returned from the Clock might be spoofed, certainly something like DateTools extension could be useful. If a developer needs to prevent someone spoofing the date and time at the device's location would be one reason to use the extension; most will not. If spoofing is a concern, the extension should be used. Most will just want to know what the date and time is where they are at the moment and those users won't adjust their device time settings. Users of an app will just want to know the date and time.
Not necessarily. Now and SystemTime are fairly precise.
Alright that's ok.
If someone wants to get correct date-time then he should always be dependent on internet.
For example, we can take WhatsApp into account. Whenever you try to misconfigure time then it warns as soon as you open the app.
If accurate time is important for functionality of your application then we shouldn't be dependent on user to provide correct time.
You are right @SteveJG
The time and location could also vary if the location in the device is turned off too. It sometimes happens to me
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.