Hey Guys.
Now that we have AppCompat support I'm curious if someone got the ShareActionProvider
to work.
I tried to follow this BlogPost but it is not getting displayed. Maybe someone knows how to get it working.
Here's my code:
[Activity(Label = "Sparen statt schuften", Icon = "@drawable/icon",Theme="@style/StandardTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
private Android.Support.V7.Widget.ShareActionProvider _actionProvider;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
ToolbarResource = Resource.Layout.Toolbar;
TabLayoutResource = Resource.Layout.TabLayout;
//ActionBar.SetIcon(Resource.Drawable.Iconfree);
if (!Insights.IsInitialized)
{
Insights.Initialize("removed", this);
Insights.Identify(Insights.Traits.GuestIdentifier, null);
}
global::Xamarin.Forms.Forms.Init(this, bundle);
SvgImageRenderer.Init();
LoadApplication(new App());
}
public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.menu, menu);
var shareItem = menu.FindItem(Resource.Id.action_share);
var test = MenuItemCompat.GetActionProvider(shareItem);
_actionProvider = test.JavaCast<Android.Support.V7.Widget.ShareActionProvider>();
var intent = new Intent(Intent.ActionSend);
intent.SetType("text/plain");
intent.PutExtra(Intent.ExtraText, "Test");
_actionProvider.SetShareIntent(intent);
return base.OnCreateOptionsMenu(menu);
}
}