title: How to implement share action in android?
body: <p>I want to implement share action in my project but when I used <code>MenuItem</code> it's giving Runtime error to use <code>MenuItemCompat</code> instead, but its too giving error.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_third_, menu);
      MenuItem menuItem = menu.findItem(R.id.menu_item_share);
  
  
      mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
  
      mShareActionProvider.setShareIntent(getDefaultShareIntent());
  
      return true;
  }
  
  public Intent getDefaultShareIntent (){
  
     Intent shareIntent = new Intent(Intent.ACTION_SEND);
  
      shareIntent.setType("text/plain");
      shareIntent.putExtra(Intent.EXTRA_SUBJECT, "SUBJECT");
      shareIntent.putExtra(Intent.EXTRA_TEXT,"Extra Text");
      return shareIntent;
  }
  </code></pre>