title: Unable to startActivity from BottomSheetDialog
body: <p>every thing works fine with this context <code>ctw = ContextThemeWrapper(cont, R.style.AppTheme)</code> but when i want to start any activity my app is crashing.
  actually this ctw works fine with Toast in this method but when i pass this ctw to Intent for starting activity is gives error. i also trying cont variable directly getApplicationContext also but still have same error. code is in kotlin you can help me in java also. :)</p>
  
  <p>Here is complete code</p>
  
  <pre><code>fun showBottomSheetDialog(url: String, cont: Context) {
  
      ctw = ContextThemeWrapper(cont, R.style.AppTheme)
  
  
      val lin_play: LinearLayout
      val lin_cancel: LinearLayout
  
      dialog = BottomSheetDialog(ctw!!)
      dialog.setContentView(R.layout.dialog_bottom_dailymotion)
      dialog.getWindow()!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
      dialog.getWindow()!!.setBackgroundDrawableResource(R.color.Transparent)
  
      lin_play = dialog.findViewById(R.id.lin_play_d)!!
      lin_cancel = dialog.findViewById(R.id.lin_cancel_d)!!
  
  
      lin_play.setOnClickListener {
          if (TextUtils.isEmpty(url)) {
              Toast.makeText(ctw, "Invalid/Empty URL", Toast.LENGTH_SHORT).show()
          } else {
              if (!url!!.isEmpty()) {
  
  
                      startActivity(Intent(ctw, MainActivity::class.java).putExtra("url", url))
  
                  dialog.dismiss()
              }
          }
      }
  
      lin_cancel.setOnClickListener {
          dialog.dismiss()
  
      }
                try {
                dialog.show()
                }catch (e:Exception){
                e.printStackTrace()
               }
          }
  </code></pre>
  
  <p>and here is my error</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.browserforvideodownload, PID: 29839
                java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
                    at android.app.Activity.startActivityForResult(Activity.java:4367)
                    at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:68)
                    at android.app.Activity.startActivityForResult(Activity.java:4312)
                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:751)
                    at android.app.Activity.startActivity(Activity.java:4716)
                    at android.app.Activity.startActivity(Activity.java:4631)
                    at com.browserforvideodownload.browserlighting.browser.activity.BrowserActivity$showBottomSheetDialogDailymotion$1.onClick(BrowserActivity.kt:3970)
                    at android.view.View.performClick(View.java:5740)
                    at android.view.View$PerformClick.run(View.java:22947)
                    at android.os.Handler.handleCallback(Handler.java:836)
                    at android.os.Handler.dispatchMessage(Handler.java:103)
                    at android.os.Looper.loop(Looper.java:232)
                    at android.app.ActivityThread.main(ActivityThread.java:6661)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1106)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>After a long Struggle i have found my mistke.</p>
  
  <p>just replace</p>
  
  <pre><code> startActivity(Intent(ctw, MainActivity::class.java).putExtra("url", url))
  </code></pre>
  
  <p>into</p>
  
  <pre><code>try{
  ctw!!.startActivity(Intent(getActivity(ctw), 
  MainActivity::class.java).putExtra("url", url))
     }catch (e:Exception){
       e.printStackTrace()
     }
  </code></pre>