I tried to implement search using EditText. whenever a text is typed in the EditText request is sent with the typed text in onTextChanged() method. When I change the orientation of the phone with the results displyed, onTextChanged() method is called again with same text. How can I avoid redundant call to onTextChanged() method on orientation change.
public void onTextChanged(CharSequence s, int start, int before, int count) {
final String enteredKeyword = s.toString();
if(isFragmentVisible && !enteredKeyword.equals("")) {
searchTimer.cancel();
searchTimer = new Timer();
TimerTask searchTask = new TimerTask() {
@Override
public void run() {
searchUser(enteredKeyword);
}
};
searchTimer.schedule(searchTask, 1500);
Log.i("", enteredKeyword);
}
}