Last active
April 21, 2019 04:53
-
-
Save AnasAlmasri/8a766dd4878279e6966514fc83abc5fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | |
| super.onActivityResult(requestCode, resultCode, data); | |
| if (resultCode == RESULT_OK && data != null) { | |
| switch (requestCode) { | |
| case 10: | |
| int intFound = getNumberFromResult(data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)); | |
| if (intFound != -1) { | |
| FIRST_NUMBER = intFound; | |
| firstNumTextView.setText(intFound); | |
| } else { | |
| Toast.makeText(getApplicationContext(), "Sorry, I didn't catch that! Please try again", Toast.LENGTH_LONG).show(); | |
| } | |
| break; | |
| case 20: | |
| intFound = getNumberFromResult(data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)); | |
| if (intFound != -1) { | |
| SECOND_NUMBER = intFound; | |
| secondNumTextView.setText(intFound); | |
| } else { | |
| Toast.makeText(getApplicationContext(), "Sorry, I didn't catch that! Please try again", Toast.LENGTH_LONG).show(); | |
| } | |
| break; | |
| case 30: | |
| char operatorFound = getOperatorFromResult(data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)); | |
| if (operatorFound != '0') { | |
| OPERATOR = operatorFound; | |
| operatorTextView.setText(operatorFound); | |
| } else { | |
| Toast.makeText(getApplicationContext(), "Sorry, I didn't catch that! Please try again", Toast.LENGTH_LONG).show(); | |
| } | |
| } | |
| } else { | |
| Toast.makeText(getApplicationContext(), "Failed to recognize speech!", Toast.LENGTH_LONG).show(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment