title: How open ProgressDialog from InputMethodService
body: <p>Why i get error from Eclipse on below code?</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>public class ServiceKeyboard extends InputMethodService implements KeyboardView.OnKeyboardActionListener
   {
     public  static ProgressDialog progressDialog;
  
  ...
     @Override public void onStartInput( EditorInfo attribute, boolean restarting)
      {
        super.onStartInput( attribute, restarting);
        progressDialog = new ProgressDialog( ServiceKeyboard.this);
        progressDialog.setMessage( getString( R.string.sSpinner));
  // after this line crash
        progressDialog.show();
  ...
  ...
        if( progressDialog != null)  progressDialog.dismiss();
      }
   }
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>11-23 12:53:07.854: E/AndroidRuntime(23963): FATAL EXCEPTION: main
  11-23 12:53:07.854: E/AndroidRuntime(23963): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.view.ViewRootImpl.setView(ViewRootImpl.java:589)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:326)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.app.Dialog.show(Dialog.java:277)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at com.avanpost.mobile.ServiceKeyboard.onStartInput(ServiceKeyboard.java:354)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.inputmethodservice.InputMethodService.doStartInput(InputMethodService.java:1549)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.inputmethodservice.InputMethodService$InputMethodImpl.startInput(InputMethodService.java:388)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:158)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.os.Handler.dispatchMessage(Handler.java:99)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.os.Looper.loop(Looper.java:137)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at android.app.ActivityThread.main(ActivityThread.java:4745)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at java.lang.reflect.Method.invokeNative(Native Method)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at java.lang.reflect.Method.invoke(Method.java:511)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  11-23 12:53:07.854: E/AndroidRuntime(23963):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>What is best solution to open window with progressDialog when softKeyboard (InputMethodService) start?</p>
  
  <p>I try "new ProgressDialog( this);", "new ProgressDialog( getApplicationContext());" instead "new ProgressDialog( ServiceKeyboard.this);", but fail.</p>