1

I have a fragment in my app where you click on a selection from an autocomplete input. When the user clicks on the selection, I want the keyboard to hide. It has been working for a while on several devices inluding my emulators in Android Studio. However when I got my Galaxy s9 the keyboard goes transparent and gets stuck when trying to hide it. This is the screen before making a selection: enter image description here

And this is after selecting: enter image description here

I have tried all methods of hiding the keyboard with the same result on the galaxy s9 including everything in this answer: https://stackoverflow.com/a/17789187/5347702

It works fine on any other device. Is this a bug on the s9 or is there something I need to differently on newer devices? (It worked fine on my s7)

Thanks

This is my current code to hide the keyboard:

if(mActivity.getCurrentFocus() != null) {
        InputMethodManager inputManager = (InputMethodManager) mActivity.getSystemService(INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }

It gets called upon selecting an option in the autocomplete(which is in a dialog):

acRecipeName.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            //get meal time from spinner
            Spinner mealTimeSpinner = mealDialog.findViewById(R.id.meal_time_spinner);
            String mealTime = mealTimeSpinner.getSelectedItem().toString();
            final String mType = mealTime.toLowerCase();
            LinearLayout llView = getLayout(mealTime);

            Recipe recipe = (Recipe)adapterView.getAdapter().getItem(i);
            String recipeId = recipe.getId();
            String recipeText = recipe.getName();
            String mealtime = mType + sdf.format(selectedDate);

            AddMeal task = new AddMeal(mealtime, recipeId, recipeText, llView, WeekViewFragment.this);
            URL addURL = NetworkUtils.buildUrl("add_to_plan", null);
            task.execute(addURL);

            hideKeyboard();

           mealDialog.dismiss();




        }
    });
Stephanie
  • 33
  • 6

0 Answers0