2014-02-17 3 views
1

저는 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의 소스 코드, 덕분에

+0

https://developers.facebook.com/docs/android/login-with-facebook/ 해시 키를 프로그래밍 방식으로 생성하기 위해 주어진 코드와 해시 키를 일치 시키거나 동일하지 않습니까? –

+0

답장을 보내 주셔서 감사합니다.하지만 불행히도 체크했습니다. 더 많은 시간을 hask 키와 일치합니다. –

+0

로그인의 기본 예제가 있습니다. 최신 SDK를 다운로드하고 사용해보십시오. –

답변

0

나는 이유를 알고 있지만, 이후의 주요 재를 다시하지 않습니다 지금까지했던 것과 같은 방식으로 페이스 북 대시 보드에 프로그램을 삽입하면 페이스 북 응용 프로그램으로 정보를 올바르게 수신 할 수 있습니다.

답장을 보내 주셔서 감사합니다 chintak khetiya.

1

이전에도이 문제가 발생했으며 디버그 키를 다시 작성하면이 문제가 해결되었습니다. 참고로 Facebook 앱 프로필에 여러 개의 키를 추가 할 수 있습니다. 모든 개발 컴퓨터와 릴리스 키에서 적어도 디버그 키를 추가 할 수 있습니다.

0

에뮬레이터를 사용하고 있습니까? 그렇다면 ARM 버전을 사용해보십시오. Intel 에뮬레이터에서 Facebook LoginActivity가 충돌합니다.

관련 문제