I have an application uploaded to Google Play. This is a link.
It has not been tested on many devices, however errors are fairly common. The user today sent me a message that the application will crash if the switch is on and the button is pressed, but not held.
This is the logcat file that he sent me:
E/MessageQueue-JNI(31135): java.lang.RuntimeException: stop failed. E/MessageQueue-JNI(31135): at android.media.MediaRecorder.stop(Native Method) E/MessageQueue-JNI(31135): at com.whizzappseasyvoicenotepad.MainActivity.stopRecording(MainActivity.java:183)
Quote:
The application does not always crash. Sometimes this happens, sometimes it is not. This only happens when the switch is on. If I touch and hold the button, it works fine, but if I touch it only for a moment, it falls. I am using Xperia S 4.1.2
I tried it on my phone, I just touched the button, and did not hold it, and it worked fine, I don’t know why this is happening on his phone.
This is the code for onTouchListener:
recBtn.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { startRecording(); } else if (event.getAction() == MotionEvent.ACTION_UP) { stopRecording(); nameAlert(); } return true; } });
And logcat says that the problem occurs when stopRecording is called, so here is the stopRecording method:
public void stopRecording() { final ImageButton recBtn = (ImageButton) findViewById(com.whizzappseasyvoicenotepad.R.id.recButton); final ToggleButton tBtn = (ToggleButton) findViewById(R.id.tBtn1); if (null != recorder) { recorder.stop(); recorder.reset(); recorder.release(); recorder = null; recBtn.setImageResource(com.whizzappseasyvoicenotepad.R.drawable.record_btn); stopTimer(); tBtn.setEnabled(true); } }
I suppose the problem is that it only touches the button for a moment, so before startRecording is fully called, stopRecoring is already called so that it will work because startRecording has not yet been fully scheduled. If so, how can I fix it? If this is not so, then what is wrong? And why such an error appears on another phone, but not mine?