title: Android java.lang.NullPointerException Crash Report
body: <p>I have a question about this error.
  So I just launch my application on google play and I got a lot of crash reports with detail like this</p>
  <pre><code>java.lang.NullPointerException: 
  at c.c.f.b.onPostExecute (:1)
  at android.os.AsyncTask.finish (AsyncTask.java:771)
  at android.os.AsyncTask.access$900 (AsyncTask.java:199)
  at android.os.AsyncTask$InternalHandler.handleMessage (AsyncTask.java:788)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:257)
  at android.app.ActivityThread.main (ActivityThread.java:8218)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:626)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1015)
  </code></pre>
  <p>But when I test it on my device and emulator, I never got that crash or error.
  There are some crash errors like that, but with different details.</p>
  <p>I'm using Android Studio with Kotlin. I would really appreciate it if anyone can help me to solve this error.</p>
  <p>Thank you so much.</p>
  <p>==============================</p>
  <p>I have a single class called <code>DataApi.kt</code> and it is called once from <code>MainActivity.class</code>.
  Inside the <code>DataApi.kt</code>, I override the <code>onPostExecute</code> method to save some data to <code>SharedPreference</code> that I need.</p>
  <p><code>DataAPI.kt</code></p>
  <pre><code>class DataAPI : AsyncTask&lt;String?, String?, String&gt;() {
      val JSON = MediaType.parse(&quot;application/json; charset=utf-8&quot;)
      private lateinit var mContext: Context
  
      fun DataAPI(context: Context) {
          mContext = context
      }
  
      override fun doInBackground(vararg p0: String?): String? {
          /* some code */
      }
  
      override fun onPostExecute(result: String) {
          super.onPostExecute(result)
          try {
              val jObj = JSONObject(result)
              PreferenceConnector.clearShared(mContext)
              PreferenceConnector.writeString(
                  mContext,
                  PreferenceConnector.DOMAIN,
                  jObj.getString(&quot;domain&quot;)
              )
          } catch (e: JSONException) {
              e.printStackTrace()
          }
      }
  }
  </code></pre>
  <p><code>MainActivity.kt</code></p>
  <pre><code>class MainActivity : AppCompatActivity() {
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
  
          window.setFlags(
              WindowManager.LayoutParams.FLAG_FULLSCREEN,
              WindowManager.LayoutParams.FLAG_FULLSCREEN
          )
  
          var api = DataAPI()
          api.DataAPI(this)
          api.execute()
          Handler().postDelayed({ init() }, 1000)
      }
  </code></pre>