title: How to open keyboard into service on Android
body: <p>In my application i should use <strong><code>Vertical Stepper</code></strong> and for this i added below <strong>library</strong> : <a href="https://github.com/ernestoyaquello/VerticalStepperForm" rel="nofollow noreferrer">VerticalStepperForm</a>.<br>
  I should use this stepper into <code>service</code> and for this i write below codes.<br>
  But when use this codes into <code>Service</code>, when click on <code>EditText</code> n<strong>ot open soft keyboard</strong> (not show me any keyboard), but when use this codes into <code>activity</code>, it's not bug and <strong>show me keyboard</strong>.<br>
  But into <code>service</code> <strong>not show any keyboard</strong>!<br></p>
  
  <p><strong>My service codes:</strong></p>
  
  <pre><code>public class FloatingLayoutService extends Service implements StepperFormListener {
  
      private WindowManager windowManager;
      private ConstraintLayout floatingLayout, floatingLay_root, floatingLay_main;
      private IBinder binder = new ServiceBinder();
      private LinearLayout floatingLay_headerLay;
      private List&lt;Step&gt; steps = new ArrayList();
      private List&lt;Integer&gt; intList = new ArrayList&lt;&gt;();
      private List&lt;TestStepsListResponse.Datum&gt; testPlans = new ArrayList&lt;&gt;();
      //Timer
      private boolean running;
      private int stepIndex = 1;
  
      @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
          windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
          //Inflate the layout using LayoutInflater
          LayoutInflater li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
          floatingLayout = (ConstraintLayout) li.inflate(R.layout.service_floating_layout, null);
          //Init view
          initUi();
          //Set layout params to display the controls over any screen.
          final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                  WindowManager.LayoutParams.MATCH_PARENT,
                  WindowManager.LayoutParams.MATCH_PARENT,
                  WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
                  WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                  PixelFormat.TRANSLUCENT);
          // From API26, TYPE_PHONE deprecated. Use TYPE_APPLICATION_OVERLAY for O
          if (Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.O)
              params.type = WindowManager.LayoutParams.TYPE_PHONE;
          //Initial position of the floating controls
          params.gravity = Gravity.BOTTOM | Gravity.START;
          params.x = 0;
          params.y = 0;
          //Add the controls view to windowManager
          windowManager.addView(floatingLayout, params);
          //Steps
          testPlans = App.testPlansList;
          for (int i = 0; i &lt; testPlans.size(); i++) {
              if (testPlans.get(i).getItemType().equals(ConstKeys.TEST_STEP_TEXT_RESPONSE)) {
                  StepDynamicEdt stepDynamicTxt = new StepDynamicEdt(testPlans.get(i).getTitle(), testPlans.get(i).getDesc());
                  // add to list
                  steps.add(stepDynamicTxt);
                  intList.add(i);
              } else {
                  StepDynamicTxt stepDynamicEdt = new StepDynamicTxt(testPlans.get(i).getTitle(), testPlans.get(i).getDesc());
                  // add to list
                  steps.add(stepDynamicEdt);
              }
          }
  
          floatingLay_stepper.setup(this, steps)
                  .allowNonLinearNavigation(false)
                  .displayCancelButtonInLastStep(false)
                  .displayBottomNavigation(false)
                  .confirmationStepTitle("OK")
                  .stepNextButtonText("Next")
                  .lastStepNextButtonText("Finish")
                  .includeConfirmationStep(false)
                  .init();
  
          return START_STICKY;
      }
  </code></pre>
  
  <p><strong>StepDynamicEdt class codes:</strong></p>
  
  <pre><code>public class StepDynamicEdt extends Step&lt;String&gt; {
  
      private static final int MIN_CHARACTERS = 1;
      private EditText editText;
      private String errorMessage;
  
      public StepDynamicEdt(String title) {
          this(title, "");
      }
  
      public StepDynamicEdt(String title, String subtitle) {
          super(title, subtitle);
      }
  
      @NonNull
      @Override
      protected View createStepContentLayout() {
          //Create view programmatically
          editText = new EditText(getContext());
          editText.setHint("User name");
          editText.setSingleLine(true);
          editText.addTextChangedListener(new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence s, int start, int before, int count) {
                  markAsCompletedOrUncompleted(true);
              }
  
              @Override
              public void afterTextChanged(Editable s) {
  
              }
          });
          editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
              @Override
              public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                  getFormView().goToNextStep(true);
                  return false;
              }
          });
  
          errorMessage = "Insert 1 character";
  
          return editText;
      }
  
      @Override
      public String getStepData() {
          Editable text = editText.getText();
          if (text != null) {
              return text.toString();
          }
          return "";
      }
  
      @Override
      public String getStepDataAsHumanReadableString() {
          String name = getStepData();
          return name == null || name.isEmpty() ? "Empty" : name;
      }
  
      @Override
      public void restoreStepData(String data) {
          if (editText != null) {
              editText.setText(data);
          }
      }
  
      @Override
      protected IsDataValid isStepDataValid(String stepData) {
          if (stepData.length() &lt; MIN_CHARACTERS) {
              return new IsDataValid(false, errorMessage);
          } else {
              return new IsDataValid(true);
          }
      }
  
      @Override
      protected void onStepOpened(boolean animated) {
          // No need to do anything here
      }
  
      @Override
      protected void onStepClosed(boolean animated) {
          // No need to do anything here
      }
  
      @Override
      protected void onStepMarkedAsCompleted(boolean animated) {
          // No need to do anything here
      }
  
      @Override
      protected void onStepMarkedAsUncompleted(boolean animated) {
          // No need to do anything here
      }
  
  }
  </code></pre>
  
  <p><strong>Update :</strong> I added below code into <code>StepDynamicEdt</code> class, but again not open keyboard!<br></p>
  
  <pre><code>InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
          Context.INPUT_METHOD_SERVICE);
  Objects.requireNonNull(imm).showSoftInput(editText, 0);
  </code></pre>
  
  <p>How can i fix it and open keyboard into <code>service</code> ?</p>