简体   繁体   English

Android,安装Facebook应用程序后Facebook登录不起作用

[英]Android, Facebook login doesn't work when the Facebook application is installed

I'm developing an application that should be connect with facebook, I followed the facebook tutorial and insert the hash key too in the facebook dashboard. 我正在开发一个应与Facebook连接的应用程序,我遵循了Facebook教程,并将哈希键也插入了Facebook仪表板。

I was able to connect with facebook but when install the facebook application I can't connect anymore with facebook, the session state is closed. 我能够与Facebook连接,但是在安装Facebook应用程序后,我再也无法与Facebook连接,会话状态已关闭。

I read several topics but I can't find a solution that is good for my problem, so I have decide to post my question, do you have any idea regard my issue? 我读了几个主题,但是找不到适合我问题的解决方案,所以我决定发布我的问题,您对我的问题有任何想法吗?

Following my source code 按照我的源代码

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;
    }
}
}

MainActivity sourcecode MainActivity源代码

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);
}

}

look forward your reply, thanks 期待您的回复,谢谢

I've encountered this before too and recreating the debug key resolved this issue for me. 我之前也遇到过这个问题,重新创建调试密钥为我解决了这个问题。 Note you can add multiple keys on the Facebook app profile, you will probably want to add at least the debug key from all development machines and the release key. 请注意,您可以在Facebook应用程序配置文件中添加多个密钥,您可能希望至少从所有开发机中添加调试密钥以及发布密钥。

I don't know why, but after recreate the key ashes in the same way that I did until now and insert in the facebook dashboard the program start to receive correctly the information by facebook application. 我不知道为什么,但是在以与现在相同的方式重新创建了骨灰之后,将程序插入到Facebook仪表板中,程序开始正确接收Facebook应用程序的信息。

Thanks chintak khetiya for your replies. 感谢chintak khetiya的回复。

Are you using the emulator? 您在使用模拟器吗? If so, try the ARM version. 如果是这样,请尝试使用ARM版本。 Facebook LoginActivity crashes on the Intel emulator. Facebook LoginActivity在Intel模拟器上崩溃。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果未安装应用程序,Facebook登录将不起作用 - Facebook login doesn't work if app is not installed Android-AuthUI-通过Facebook登录时,firebase无法正常工作 - Android - AuthUI - firebase doesn't work when login by facebook 没有Facebook应用的Android Facebook SDK 4登录无法正常工作 - Android Facebook SDK 4 login without Facebook app doesn't work 安装FB应用程序时,Android Facebook示例应用程序无法登录 - Android Facebook sample app doesn't login when FB app installed 如果设备中安装了 facebook 应用程序,则在我的 android 应用程序中登录 facebook 会出现问题 - Issue with facebook login in my android application if facebook application is installed in device Facebook登录:它不会重定向到已安装的Facebook应用程序吗? - Facebook Login: It doesn't redirect to the Facebook app installed? 如果在模拟器上安装了Facebook应用,则无法登录到Facebook-Android 4.3 - Login to facebook does not work if facebook app is installed on emulator - Android 4.3 使用 Facebook 的 Android 应用程序登录不适用于已安装的 Facebook 应用程序 - Android Application Login with Facebook is not working with Facebook App installed Android Facebook登录在调试中工作,在发布的应用程序中不起作用 - Android Facebook login works in debug, doesn't work in published app Android:Facebook 登录不起作用,没有错误消息 - Android: Facebook login doesn't work, no error message
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM