我已經在我的應用程序中包含Fb登錄,當我點擊「登錄」按鈕(com.facebook.widget.LoginButton)時,它將在登錄之前用對話框打開額外的活動,如下面的圖片。爲什麼發生這種情況?我不想在登錄前打開這個額外的活動。任何想法如何做到這一點?Android - facebook sdk問題
我的主要活動:
public class MainActivity extends SherlockFragmentActivity {
//Button fblogin;
Button signup_with_email;
Button log_in;
private UiLifecycleHelper uiHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(this, null);
uiHelper.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initialize();
setListeners();
}
private void initialize() {
//fblogin = (Button) findViewById(R.id.login_button);
signup_with_email = (Button) findViewById(R.id.signup_with_email);
log_in = (Button) findViewById(R.id.log_in);
}
private void setListeners() {
/*fblogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
*/
signup_with_email.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this,
EmailSignUpActivity.class));
}
});
log_in.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, LoginActivity.class));
}
});
}
@Override
protected void onResume() {
super.onResume();
uiHelper.onResume();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
uiHelper.onSaveInstanceState(outState);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data);
startActivity(new Intent(MainActivity.this, DashBoardActivity.class));
}
@Override
public void onPause() {
super.onPause();
uiHelper.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
我加入了Session.StatusCallback如u建議,但存在同樣的問題,當我點擊在登錄按鈕上,它打開另一個對話框,然後打開facebook應用程序進行授權 –
但是,我創建另一個示例應用程序只有登錄按鈕,它工作正常。這裏是我的其他代碼工作正常http://pastebin.com/QjMg7xdS –
在這種情況下,UiLifeCycleHelper與簡單顯示的額外活動無關,因此這不能解決Suresh的問題。解決方案很簡單,請參閱我的答案瞭解詳情。 – wkarl