11
I am now doing a little project that want to have a share button(dialog), when users click it, it will auto-login to his/her fb account and share the content they want.
After the tutorial from fb dev, my app can share content to wall, but need to login with a fblogin button before sharing.
I have read a post from stackoverflow: Android - Facebook SDK 3 - How to login programmatically without LoginButton
UPDATE: I have implement the feedDialog with onActivityResult in my project, I found that i can login and share with one button. HOWEVER, when i rebuild the app/restart my phone, i have to press the button twice to share at the first time, but become normal(press once) later.
P.S.I have implement it with shareActionProvider
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getSupportMenuInflater().inflate(R.menu.content_main, menu);
/** Getting the actionprovider associated with the menu item whose id is share */
mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.share).getActionProvider();
/** Getting the target intent */
Intent intent = getDefaultShareIntent();
/** Setting a share intent */
if(intent!=null){
mShareActionProvider.setShareIntent(intent);
mShareActionProvider.setOnShareTargetSelectedListener(new OnShareTargetSelectedListener(){
@Override
public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
if ("com.facebook.katana".equals(intent.getComponent().getPackageName())){
if (Session.getActiveSession() == null || Session.getActiveSession().isClosed()) {
Se