我已经通过我的应用程序中的这个代码部分解决了。这将在两种情况下都给出响应,即安装或未安装本机应用程序。
这是一个链接
import com.facebook.AsyncFacebookRunner;
import com.facebook.DialogError;
import com.facebook.Facebook;
import com.facebook.Facebook.DialogListener;
import com.facebook.FacebookError;
import com.facebook.Session;
import com.facebook.SessionState;
facebook = new Facebook( APP_ID );
mAsyncRunner = new AsyncFacebookRunner( facebook );
loginWithFB();
public void loginWithFB()
{
if(!facebook.isSessionValid()) {
facebook.authorize(Login.this, new String[] {"publish_stream","read_stream", "offline_access"}, //Facebook.FORCE_DIALOG_AUTH,
new DialogListener() {
@Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", facebook.getAccessToken());
editor.putLong("access_expires", facebook.getAccessExpires());
editor.commit();
}
@Override
public void onFacebookError(FacebookError error) {Log.e("FB:","Facebook Error" );}
@Override
public void onError(DialogError e) {Log.e("FB:","Error" );}
@Override
public void onCancel() {}
});
}
}
@Override
public void onActivityResult( int requestCode, int resultCode, Intent data )
{
super.onActivityResult( requestCode, resultCode, data );
facebook.authorizeCallback( requestCode, resultCode, data );
}