How to determine if my Android uses a comma or decimal separator.

3,442 views
Skip to first unread message

SteveJG

unread,
Jul 9, 2014, 10:04:46 AM7/9/14
to mitappinv...@googlegroups.com
Localization is an issue even Google has not totally solved regarding Android apps.The AI2  location sensor reports latitude and longitude using a period or dot decimal 
separator, so if I develop an AI2 app in North America how can I be sure it can be used in Europe without decimal point issues?

The attached blocks probably can allow developers to pre-determine what system  decimal separator is active on any device and write appropriate code Blocks so their app works 
World-wide.

The blocks shown work on my tablet using Android 4.2.2.    Do the blocks work on your Android that uses a comma separator?
I do not know and can not test on my device.  Be aware, the actual routine is the simple if test...most users do not need all the extra stuff.   





AI2 developers using comma centric floating point values in your Android devices , can you please confirm this approach works (or not) ?   Or, is there a better way?

Thank you.

SteveJG

Taifun

unread,
Jul 9, 2014, 10:15:35 AM7/9/14
to
App Inventor uses dot as decimal separator
so if you want your app work worldwide, just always replace comma by dot
for example after having received a value from the location sensor or from a user input (textbox)

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.                

Message has been deleted

kitche...@hotmail.com

unread,
Jul 10, 2014, 7:02:20 PM7/10/14
to mitappinv...@googlegroups.com
I noticed this issue too. In particular I incurred in this while testing the app "Android, where's my car?"
Whenever I press the button to ask for directions, Google Maps opens and warns:"No results for xx,xxxxx,yy,yyyyy"
The point is, how can I make the LocationSensor1 generate coordinates with a dot separator rather than comma? If I can't fix this, the app is useless.
Thank youin advance

Seguuro

SteveJG

unread,
Jul 10, 2014, 9:07:51 PM7/10/14
to
It is easily fixed.   You did not understand  the explanation of how to fix the blockst.
You replace the commas with a decimal as in the comma to period blocks.



When you pass these values   xx,xxxxx,yy,yyyyy    convert them to xx.xxxx and yy.yyyy using the replace block with the segment being a comma and the replacement being a period.

Just try some blocks.   If you run into trouble, post what you tried as an image of your blocks (jpg or png) and you will get advice.

did it work for you?

(incidentally, the LocationSensor passes information using a decimal period separator.   Something else in you app is using the comma separator format...change that)

Regards,
Steve

kitche...@hotmail.com

unread,
Jul 11, 2014, 4:15:02 AM7/11/14
to mitappinv...@googlegroups.com
Is that so? It is strange. Sure, I'm a novice and I don't really know what is using the comma separator or how to locate it either.. but I can assure you that I just followed the instructions given by the tutorial. I can't figure out why this happened. What I did was just rename the labels and buttons with a different pattern. And as a novice I don't even know what and where is that replace block you are speaking of!
Please, can you give me a hint on how to proceed? Just don't get too technical!
Any help will be greatly appreciated


Seguuro

SteveJG

unread,
Jul 11, 2014, 8:21:08 AM7/11/14
to mitappinv...@googlegroups.com
Seguuro,

1) I do not have a copy of the tutorial you are using.  The tutorial probably does not have a piece that shows how to replace periods or commas using code .. it was written by someone who uses a period decimal separator and he/she did not know there are issues with comma centric Android devices.

2)  You can take a picture of your blocks screen, attach it to your note here using the icon to the left of Link above.   You did not mention what your operating system is.   How to do that is different for Macs and Windows Pcs.

3)  The block you need is described here    http://appinventor.mit.edu/explore/ai2/support/blocks/text.html                       and is found in the Text , and accessed on the Blocks screen 

replace all

Returns a new text string obtained by replacing all occurrences of the substring with the replacement.

Replace all with She loves eating. She loves writing. She loves coding as the text, She as the segment, and Hannah as the replacement would result inHannah loves eating. Hannah loves writing. Hannah loves coding.


4)  The tutorial you are using is probably designated as an Advanced project.  At the moment, you probably do not know a lot of things necessary to develop easily with AI2.  That can be fixed.   Try the tutorials here:           http://appinventor.mit.edu/explore/ai2/beginner-videos.html                 and http://appinventor.mit.edu/explore/ai2/tutorials.html  .    Start with the basic tutorials..    You can also read an online book.   It is free and is almost like taking a course in how to program AI2 ...http://www.appinventor.org/book2 


5) The things you need to do "fix" the code in the tutorial to work in your environment are not difficult but you have to understand the tools we talk about.

6)  Was this helpful?    Do you need anything explained more?   We are glad to help, but to help, I and others need to see some blocks and you need to do the basic tutorials I believe.

7)  Still having issues?    Please do return here and someone will try to work you through the fix.

8)  Did you find the replace block?

Regards,
Steve


Hillechien

unread,
Jul 11, 2014, 8:32:59 AM7/11/14
to
It may be true that the LocationSensor returns dots instead of comma's, but as soon as you try to convert it to text, because you want to pass the values in the activity starter to googe maps for example, the dots are converted to comma's. This is unavoidable if you have a mobile phone in a country where the decimal separator is a comma. 
I assume that the location sensor returns a decimal value and not text? that could explain the problem. Mayby it would be nice to have latAsText and longAsText as get operations...

I tried the latest greatest AI2 AndroidWheresMyCar and it does not work here in the Netherlands, unless I change the , to . and then still, I never see the real address, because the LocationSensor does not seem to be able to find it. Fortunately Google maps can find it.

SteveJG

unread,
Jul 11, 2014, 8:41:06 AM7/11/14
to mitappinv...@googlegroups.com
@ Hillechen

Exactly, the locationSensor returns a period decimal separator number.      Do you know how to use the Do It debugger within AI2?     You can use that to help figure out what you need to change and where the change needs to occur.     Post some blocks.    Perhaps the guys here can help you figure it out.       I am aware of several developers who have a similar problem and they solved them.  So can you.

Regards,
Steve

Taifun

unread,
Jul 11, 2014, 10:41:44 AM7/11/14
to mitappinv...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages