Android Get Sim State
<p>I am trying to print the sims state to screen. At the moment I cannot seem to get it to work.
What I want to be able to do is print if a sim card is locked or not.</p>

<p>I have been using this code</p>

<pre><code>    TelephonyManager manager = (TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE);
    int state = manager.getSimState();
    answer1.setText(state);
</code></pre>

<p>but the LogCat output is</p>

<blockquote>
  <p>ERROR/AndroidRuntime(213): Uncaught handler: thread main exiting due to uncaught exception
  ERROR/AndroidRuntime(213): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.q.m/com.q.m.Q}: java.lang.NullPointerException
  ERROR/AndroidRuntime(213):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
  ERROR/AndroidRuntime(213):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
  ERROR/AndroidRuntime(213):     at android.app.ActivityThread.access$2100(ActivityThread.java:116)
  ERROR/AndroidRuntime(213):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
  ERROR/AndroidRuntime(213):     at android.os.Handler.dispatchMessage(Handler.java:99)
  ERROR/AndroidRuntime(213):     at android.os.Looper.loop(Looper.java:123)
  ERROR/AndroidRuntime(213):     at android.app.ActivityThread.main(ActivityThread.java:4203)
  ERROR/AndroidRuntime(213):     at java.lang.reflect.Method.invokeNative(Native Method)
  ERROR/AndroidRuntime(213):     at java.lang.reflect.Method.invoke(Method.java:521)
  ERROR/AndroidRuntime(213):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
  ERROR/AndroidRuntime(213):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
  ERROR/AndroidRuntime(213):     at dalvik.system.NativeStart.main(Native Method)
  ERROR/AndroidRuntime(213): Caused by: java.lang.NullPointerException
  ERROR/AndroidRuntime(213):     at com.q.m.Q.onCreate(Q.java:77)
  ERROR/AndroidRuntime(213):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
  ERROR/AndroidRuntime(213):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
  ERROR/AndroidRuntime(213):     ... 11 more</p>
</blockquote>

<p>Line 77 is the </p>

<blockquote>
  <p>TelephonyManager manager = (TelephonyManager) </p>
</blockquote>

<p>Line</p>
