저는 Facebook에 연결해야하는 응용 프로그램을 개발 중이며, Facebook 개인 지도서에 따라 Facebook 대시 보드에 해시 키를 삽입합니다.Facebook 응용 프로그램이 설치된 경우 Android, Facebook 로그인이 작동하지 않습니다.
페이스 북에 연결할 수 있었지만 페이스 북 응용 프로그램을 설치할 때 페이스 북에 더 이상 연결할 수 없으면 세션 상태가 닫힙니다.
몇 가지 주제를 읽었지만 내 문제에 대해 좋은 해결책을 찾을 수 없으므로 내 질문을 게시하기로 결정 했으므로 내 문제에 관해 의견이 있으십니까? 내 소스 코드를 다음
public class FragmentSn extends Fragment {
private static final String TAG = "FragmentSn";
private UiLifecycleHelper uiHelper;
static boolean fbLoggedIn;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragmentsn, container, false);
LoginButton authButton = (LoginButton) rootView.findViewById(R.id.authButton);
authButton.setReadPermissions(Arrays.asList("basic_info", "email"));
authButton.setFragment(this);
return rootView;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
}
@Override
public void onResume() {
super.onResume();
// For scenarios where the main activity is launched and user
// session is not null, the session state change notification
// may not be triggered. Trigger it if it's open/closed.
Session session = Session.getActiveSession();
if (session != null &&
(session.isOpened() || session.isClosed())) {
onSessionStateChange(session, session.getState(), null);
}
uiHelper.onResume();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data, new
FacebookDialog.Callback(){
@Override
public void onError(FacebookDialog.PendingCall pendingCall, Exception error,
Bundle data) {
Log.e("Activity", String.format("Error: %s", error.toString()));
}
@Override
public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) {
Log.i("Activity", "Success!");
}
});
}
@Override
public void onPause() {
super.onPause();
uiHelper.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
uiHelper.onSaveInstanceState(outState);
}
private Session.StatusCallback callback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
onSessionStateChange(session, state, exception);
}
};
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
fbLoggedIn=true;
} else if (state.isClosed()) {
fbLoggedIn=false;
}
}
}
public class MainActivity extends ActionBarActivity {
// Declare Tab Variable
ActionBar.Tab Tab1, Tab2, Tab3,Tab4;
Fragment fragmentMap = new FragmentMap();
Fragment fragmentCoupon = new FragmentCoupon();
Fragment fragmentCampaign = new FragmentCampaign();
Fragment fragmentSn = new FragmentSn();
Tools tools;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getSupportActionBar();
// Hide Actionbar Icon
actionBar.setDisplayShowHomeEnabled(false);
// Hide Actionbar Title
actionBar.setDisplayShowTitleEnabled(false);
// Create Actionbar Tabs
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Set Tab Icon and Titles
Tab1 = actionBar.newTab().setIcon(this.getResources().getDrawable(R.drawable.tab_map));
Tab2 = actionBar.newTab().setIcon(this.getResources().getDrawable(R.drawable.tab_coupon));
Tab3 = actionBar.newTab().setIcon(this.getResources().getDrawable(R.drawable.tab_campaign));
//Tab4 = actionBar.newTab().setIcon(this.getResources().getDrawable(R.drawable.tab_sn));
// Set Tab Listeners
Tab1.setTabListener(new TabListener(fragmentMap));
Tab2.setTabListener(new TabListener(fragmentCoupon));
Tab3.setTabListener(new TabListener(fragmentCampaign));
//Tab4.setTabListener(new TabListener(fragmentSn));
// Add tabs to actionbar
actionBar.addTab(Tab1);
actionBar.addTab(Tab2);
actionBar.addTab(Tab3);
//actionBar.addTab(Tab4);
// Facebook - START
if (savedInstanceState == null) {
// Add the fragment on initial activity setup
fragmentSn = new FragmentSn();
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, fragmentSn)
.commit();
} else {
// Or set the fragment from restored state info
fragmentSn = (FragmentSn) getSupportFragmentManager().findFragmentById(android.R.id.content);
}
// Facebook - END
// AM 2014/01/15 - START
//Check update information
tools = new Tools(this.getApplicationContext());
// AM 2014/01/15 - END
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
}
앞으로 귀하의 회신을 볼
MainActivity의 소스 코드, 덕분에
https://developers.facebook.com/docs/android/login-with-facebook/ 해시 키를 프로그래밍 방식으로 생성하기 위해 주어진 코드와 해시 키를 일치 시키거나 동일하지 않습니까? –
답장을 보내 주셔서 감사합니다.하지만 불행히도 체크했습니다. 더 많은 시간을 hask 키와 일치합니다. –
로그인의 기본 예제가 있습니다. 최신 SDK를 다운로드하고 사용해보십시오. –