android - facebook share doesn't work, when click share from the action bar -
i've used below code place share button in action bar, share particular text. when click share, works messaging , email etc when click facebook. facebook opened on create status bit, although share text below code not there.
what have done wrong? or there need add or change?
xml:
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menu_item_share" android:showasaction="ifroom" android:title="share" android:actionproviderclass="android.widget.shareactionprovider" /> </menu> activitymain:
@override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.action_bar_share_menu, menu); menuitem item = menu.finditem(r.id.menu_item_share); shareactionprovider myshareactionprovider = (shareactionprovider) item.getactionprovider(); intent myintent = new intent(); myintent.setaction(intent.action_send); myintent.putextra(intent.extra_text, "whatever message want share"); myintent.settype("text/plain"); myshareactionprovider.setshareintent(myintent); return true; }
facebook might looking extra_subject.
untested many trolls on fb.
private intent createshareintent() { intent shareintent = new intent(intent.action_send); shareintent.settype("text/plain"); string s = getstring(r.string.sharetext); shareintent.putextra(intent.extra_text, s); s = getstring(r.string.sharesubject); shareintent.putextra(intent.extra_subject, s); return shareintent; } using appcompat actionbar.
menuitem menuitem = menu.finditem(r.id.menu_item_share); // fetch , store shareactionprovider mshareactionprovider = (shareactionprovider) menuitemcompat .getactionprovider(menuitem); mshareactionprovider.setshareintent(createshareintent());
Comments
Post a Comment