title: Android: Starting ActionMode inside ViewPager's Fragment
body: <p>I am working on an app where I have a viewpager with 3 fragments in it using  Tablayout. Now I am trying to start the actionmode for Recycler view to select multiple views on LongClick. Below is the code </p>
  
  <pre><code>actionMode = ((AppCompatActivity)getActivity()).startSupportActionMode(actionModeCallback);
  </code></pre>
  
  <p>but it always give me this error</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v7.view.ActionMode android.support.v7.app.AppCompatActivity.startSupportActionMode(android.support.v7.view.ActionMode$Callback)' on a null object reference
  </code></pre>
  
  <p>I have also tried it like this</p>
  
  <pre><code>MyMainActivity activity=(MyMainActivity)getActiivty();
  activity.startSupportActionMode(actionModeCallback);
  </code></pre>
  
  <p>But it gaves me the same error. Any help will be highly appreciated. Thanks in advance </p>