Reputation: 1482
I have edit text with value "11491992"
sometimes when try to edit it, app is freezed and logcat has this
Timeout waiting for IME to handle input event after 2500 ms: com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME
[Update]
I have some EditText views and use RxBinding to control enable/disable submit button based on these EditText views
val bag = CompositeDisposable()
RxTextView.textChanges(edFirstName)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.map { it.toString().trim() }
.subscribe {
btnSubmit.isEnabled = it.isNotBlank()
updateRequest.firstName = it
}.addTo(bag)
RxTextView.textChanges(edLastName)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.map { it.toString().trim() }
.subscribe {
btnSubmit.isEnabled = it.isNotBlank()
updateRequest.lastName = it
}.addTo(bag)
Upvotes: 3
Views: 840
Reputation: 1658
This code is OK.
val bag = CompositeDisposable()
RxTextView.textChanges(edFirstName)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.map { it.toString().trim() }
.subscribe {
btnSubmit.isEnabled = it.isNotBlank()
}.apply { bag.add(this) }
RxTextView.textChanges(edLastName)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.map { it.toString().trim() }
.subscribe {
btnSubmit.isEnabled = it.isNotBlank()
}.apply { bag.add(this) }
}
ANR happens when a long operation is taking place on the main thread. If this thread is busy, Android cannot process any further GUI events in the application, and thus throws up an ANR Application Not Responding
dialog.
From the source code of android.view.inputmethod.InputMethodManager
see this function void finishedInputEvent(int seq, boolean handled, boolean timeout) { ... }
if (timeout) {
Log.w(TAG, "Timeout waiting for IME to handle input event after "
+ INPUT_METHOD_NOT_RESPONDING_TIMEOUT + " ms: " + p.mInputMethodId);
} else {
mH.removeMessages(MSG_TIMEOUT_INPUT_EVENT, p);
}
Also always try to handle all timeconsuming operations on any thread other than the main thread.
see How an app hanged without an ANR?
Upvotes: 1