What is wrong with the code:
String maintext = (String) main_text.getText().toString();
if(maintext =="10") {
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
}
The code is working without if statement but with the use of if and .getText().toString()
is not working at all.
== tests object references, .equals() tests the string values.
use
equals
Finally