Does anyone know why TalkBack reads the text "Balance: $0.00" as simply "Balance"? It seems to ignore values equivalent to zero. I would expect it to be read as "Balance: zero dollars."
view.announceForAccessibility("Total: $0.00"); // Reads "Total"
view.announceForAccessibility("Total: $0"); // Reads "Total"
view.announceForAccessibility("Total: 0"); // Reads "Total: Zero"
I filed a bug on the Android project, but was wondering if anyone here had some insight.
This is a bug in the text-to-speech engine, and should be fixed in later versions of the engine.
To work around it, you can either use a different TTS engine (ex. SVOX Classic) or specify the announcement as "Total: zero dollars" when you know the value is zero.
Related
Any one have idea of getting language of user, who is typing in the EditText.
What I Have Tried ?
Please do not suggest Google's com.google.mlkit , I have already tried but not working when user types fast.
I have also tried setting up android:digits="All Alfabets", It is not working when I long press and paste from the ClipBoard, It is allowing text from the other language.
This seems like a very complex problem! And one that limiting the allowed characters won't solve - many non-English languages use the same Latin character set as English, or use it for a romanised version of their written language. nihongo o kaite imasu is Japanese, but that would pass an alphabet check!
Even where other characters are used (e.g. accented versions) it's not unusual for people to just drop them and use the "standard English" characters when typing, especially if they're being informal - e.g. Spanish uses accents on question words like ¿qué?, but people might just not bother (and skip the ¿ too, or just say k if they're being really informal)
And then there's the fact that English does use accented characters - someone can be naïve or blasé, but you don't want your app to tell people they're "not typing in English" if they write those things.
I don't know anything about mlkit but if it's capable of detecting language to some decent degree, it really might be the way to go for such a complex human problem. I'd suggest that instead of trying to interfere with the user's typing, you just trigger a check when they're done which validates what they've entered. If it looks ok, you can enable a button or whatever - if not, show an error message and make them fix it themselves.
You could do that kind of thing with a TextWatcher (or the doAfterTextChanged extension function that comes with the ktx-core AndroidX library) - you'd probably want to start a delayed task so it happens a moment after they stop typing, and that you can interrupt if they start typing again
val languageCheck = Runnable {
// do your check here, enable buttons / show errors as a result
}
// set up the checker
textView.doAfterTextChanged {
// cancel an existing delayed task
textView.removeCallbacks(languageCheck)
// schedule a new one
textView.postDelayed(languageCheck, delayMillis)
}
I'm actually using Math.sin() in my android app to calculate a sinus of a given angle (using Math.toRadians(angle_in_degrees)). For exemple when I want to get the Math.cos(90) which is 0, the result is 6.123233... E-17. Thanks you.
For floating point numbers, the system can often only approximate their values. For instance, the system would return something like 0.333333 for the expression (1.0 / 3). The number of 3s after the decimal point will be different depending on whether you're a floats or doubles, but it will still be limited to some finite length.
If you're just displaying the value, then you can limit the number of digits using something like String.format("%0.2f", value) or by rounding it using one of the rounding functions such as Math.round().
The tricky part comes when you need to compare the value to something. You can't just use if (value == some_constant) or even if (value == some_variable). At minimum, you usually have to use something like if (Math.abs(value - some_constant) < 0.001). The actual value of the '0.001' depends on the needs of your particular application and is customarily defined as a named constant.
For more complicated needs, you can implement the algorithm in the Floating-Point Guide.
You're getting back an approximation from Math.cos(Math.toRadians(90)) which is
6.123233... E-17 == 0.00000000000000006123233... which is basically 0
The following link should help clear things up as far as the precision of doubles/floats in programming.
http://www.java67.com/2015/09/float-and-double-value-comparison-in-java-use-relational.html
I am beginner and trying to write some calculations with App Inventor 2.
I am trying to write a code to calculate Net present value.
The formula of NPV = - investment + CF/(1+i)power up by years of investment, which means if years of investment are > 1 the second part of formula will repeat until it reached the number of years.
I successfully code the formula for one year that works correct, but have problem with the "repeating" the second part powered by number of years.
I tried to declare years as variable to use it as powering number but think something is wrong with it.
In my opinion I need to split the powering number somewhere to memory and then increase it by 1 until the required number. However have no clue how to do it.
Can anyone help?
Screenshot of the blocks
Following the calculation from the NPB Calculator,
this is converted into blocks the following
Note: for a better clarity and to avoid such long calculation blocks as in your screenshot, I used External Inputs instead of Inline Inputs, which is the default. You can switch that from the context menu after doing a right mouse click onto one of the calculation blocks.
EDIT: screenshot updated for changing cashflows using a list.See also
How to work with Lists by Saj and
How to work with Lists and Lists of lists (pdf) by appinventor.org
Thanks for reading this question. I am sure the experts on this site will be able to provide the help I need.
I am trying to write an app which allows users to edit the exif information of the photos on their Android Phone.
As a part of improved user experience, I want to apply data validation where ever possible.
For the Exif Tag - TAG_GPS_PROCESSING_METHOD I am not able to apply the validation correctly.
Here is the part of code that I have applied :
String strGPSProc = etGPSProc.getText().toString();
if(strGPSProc.equalsIgnoreCase("GPS") || strGPSProc.equalsIgnoreCase("CELLID") || strGPSProc.equalsIgnoreCase("WLAN") || strGPSProc.equalsIgnoreCase("MANUAL") ) {
returnValue = true;
}else {
returnValue=false;
showToast("Incorrect value for GPS Processing Method. Correct value options are GPS, CELLID, WLAN or MANUAL.");
etGPSProc.requestFocus();
}
This code checks if the value entered in the EditText meant for GPSProcessingMethod, has any one of the four prescribed value as described in the documentation of EXIF.
But when I try to save this using setAttribute() and saveAttributes() functions, a non catch-able exception appears in logcat.
Unsupported encoding for GPSProcessingMethod
I understand from Exif Documentation that values for GPSProcessingMethod needs to be stored with some header information.
I need some expert advise on how to implement this correctly, with out using any other 3rd part classes.
Accoridng to the Exif specification:
GPSProcessingMethod
A character string recording the name of the method used for location finding. The first byte indicates the character
code used (Table 6、Table 7), and this is followed by the name of the method. Since the Type is not ASCII, NULL
termination is not necessary
Atually, Table 6 lists the character codes as 8 byte sequences, so the above should probably read "The first bytes indicate...". Anyway, the character code designation for ASCII is defined as 41.H, 53.H, 43.H, 49.H, 49.H, 00.H, 00.H, 00.H., Unicode is (unsurprisingly) 55.H, 4E.H, 49.H, 43.H, 4F.H, 44.H, 45.H, 00.H. I guess these should be all you need.
Hope that helps.
EDIT:
Just discovered that ExifInterface.setAttribute() only supports String values... You could try encoding the value at the beginning of your string, but I doubt that would work. Sounds like the encoding should be handled by the setAttribute() or saveAttributes() method. Could it be a bug in the API? I had a look at the source code, but the actual writing of values is done by native code so I stopped digging further.
i am new to android development,so dint get me wrong. I am developing an application in which a text is generated.which is normally a word. The word is checked in a database for is corresponding value pair. Here the word is the key and its corresponding value is the value .
Since the text is auto generated it sometimes goes wrong(mis spelled). How do i perform a check of auto generated word to match with the mostly matched letters in the database of key word.
example: auto-generated word(key) - value
americ:
america : a country
Here the auto generatd word is americ(key) is not matched since it only contains america in its pair set.it need to be corrected as america.
You are probably using SQLite. Your best bet is soundex, which is desribed here.
Soundex has many shortcomings, but it might get you started. If you want a real measure, then go with Levenshtein distance, which is not built into the database (as far as I know).