How to specify min and/or max length in RemoteInput

273 Views Asked by At

I use RemoteInput in my Android N notifications.

I want to set a min and max text length limit for the input.

Google Hangouts got this (i.e. the send button enables when the user entered at least 1 character). Anyone know how this can be done? I've tried to check the Android docs but no luck.

2

There are 2 best solutions below

0
On

Try to implements notification with custom view. And include in it all logic which you need. For me it is one way((

2
On
 button.setClickable(false);
    button.setEnabled(false);
    editText = (EditText)findViewById(R.id.editText);


    editText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            button.setClickable(true);
            button.setTextColor(getResources().getColor(R.color.colorPrimary));
            // TODO Auto-generated method stub
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {

            // TODO Auto-generated method stub
        }
    });



}