title: NullPointerException while attempting to invoke fragment interface method
body: <p>I'm trying to send some data to my Activity from Fragment by creating interface. </p>
  
  <p>So First I created an Interface in my Fragment Class,</p>
  
  <pre><code>public interface OnMediaSelected{
          public void onItemPicked(String url, String type);
  
      }
  </code></pre>
  
  <p>Then initialized the callback variable at onAttach method,</p>
  
  <pre><code>   @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
          callback = (OnMediaSelected) activity;
      }
  </code></pre>
  
  <p>And in another method I called my Interface callback,</p>
  
  <pre><code>public void Action(String url,String type){
      Log.i("data check",url);
      try {
          callback.onItemPicked(url,type);
      }catch (Exception e){
          Log.i("Error",e.toString());
  
      }
  }
  </code></pre>
  
  <p>None of those data (url, type) are null.</p>
  
  <p>But when I run this app, I'm getting this error</p>
  
  <pre><code>Attempt to invoke interface method 'void com.buckydroid.app.MoreOptions$OnMediaSelected.onItemPicked(java.lang.String, java.lang.String)' on a null object reference
  </code></pre>