diff --git a/src/android/SpeechRecognition.java b/src/android/SpeechRecognition.java index 023a140..f1da019 100644 --- a/src/android/SpeechRecognition.java +++ b/src/android/SpeechRecognition.java @@ -67,7 +67,7 @@ public void onRequestPermissionResult(int requestCode, String[] permissions, { if(r == PackageManager.PERMISSION_DENIED) { - fireErrorEvent(); + fireErrorEvent(r); fireEvent("end"); return; } @@ -204,10 +204,11 @@ private void fireEvent(String type) { this.speechRecognizerCallbackContext.sendPluginResult(pr); } - private void fireErrorEvent() { + private void fireErrorEvent(int error) { JSONObject event = new JSONObject(); try { event.put("type","error"); + event.put("error",error); } catch (JSONException e) { // this will never happen } @@ -245,7 +246,7 @@ public void onEndOfSpeech() { public void onError(int error) { Log.d(LOG_TAG, "error speech "+error); if (listening || error == 9) { - fireErrorEvent(); + fireErrorEvent(error); fireEvent("end"); } listening = false;