How to use InputMethodService in activity?
<p>I have activity class </p>

<pre><code>public class Login extends Activity  
</code></pre>

<p>I create class inside Login class</p>

<pre><code>public  class Keyclass extends InputMethodService
    {
        void addtext()
        {
            InputConnection ic =  getCurrentInputConnection();
             ic.commitText("1", 1);
        }
    }
</code></pre>

<p>And try to use it in onClick event:</p>

<pre><code>Button but1=(Button) findViewById(R.id.button1);
         but1.setOnClickListener(new OnClickListener() 
            {
                @Override
                public void onClick(View arg0) 
                {
                    Keyclass kk= new Keyclass();
                    kk.onkey();
                }
            });
</code></pre>

<p>But get error:</p>

<blockquote>
  <p>02-26 21:28:18.903: E/AndroidRuntime(747): FATAL EXCEPTION: main 02-26
  21:28:18.903: E/AndroidRuntime(747): java.lang.NullPointerException</p>
</blockquote>
