I wanted the called item to appear on your side as well:
Theresultyou'dexpectwouldbethis:
Activity code with the help of @Alexandre Strevenski:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.ShareActionProvider;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends Activity {
private ShareActionProvider mShareActionProvider;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_activity_actions, menu);
MenuItem shareItem = menu.findItem(R.id.acao4);
mShareActionProvider = (ShareActionProvider)
MenuItemCompat.getActionProvider(shareItem);
mShareActionProvider.setShareIntent(getDefaultIntent());
return super.onCreateOptionsMenu(menu);
}
private Intent getDefaultIntent() {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
return intent;
}
}
main_activity_actions.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/acao1"
android:icon="@android:drawable/ic_menu_delete"
android:showAsAction="ifRoom|withText"
android:title="deletar"/>
<item
android:id="@+id/acao2"
android:icon="@android:drawable/ic_menu_add"
android:showAsAction="ifRoom|withText"
android:title="adicionar"/>
<item
android:id="@+id/acao3"
android:icon="@android:drawable/ic_menu_camera"
android:showAsAction="ifRoom|withText"
android:title="camera"/>
<item
android:id="@+id/acao4"
android:icon="@android:drawable/ic_menu_call"
android:showAsAction="ifRoom|withText"
android:title="chamada"
yourapp:actionProviderClass="android.support.v7.widget.ShareActionProvider"/>
</menu>
Note: I have already used android: actionProviderClass="android.support.v7.widget.ShareActionProvider" and it is not working either.
Error Log: