Android Facebook-Connect button needs to be clicked two times
<p>since hours I am trying to figure out why my facebook-connect is not working properly. I always have to click it two times.. the first time I click it I see that the facbeook dialog is opening but its not calling any kind of callback so my Login-Activity is just "resuming".</p>

<pre><code>public void onClick_fbIcon(View v) {
    if(!buttonsEnabled)
        return;

    buttonsEnabled = false;
    tryFacebookConnect();
}

@SuppressWarnings("deprecation")
private void tryFacebookConnect() {
    Log.d("debug", "start fbc");
    doingFacebooklogin = true;
    facebook.authorize(this, new DialogListener() {
        public void onComplete(Bundle values) {
            end();
            toast("Complete");
            Log.d("debug", "#0");   
            // .. continue with main code
        }

        public void onFacebookError(FacebookError error) {
            end();
            Log.d("debug", "#1");           
        }

        public void onError(DialogError e) {
            end();
            Log.d("debug", "#2");
        } 

        public void onCancel() {
            end();
            Log.d("debug", "#3");
        }

        private void end() {
            Log.d("debug", "fbc complete");
            doingFacebooklogin = false;
        }
    });
}
</code></pre>

<p>The first click I only get "start fbc" but nothing after that, so I guess that no callback method is called.</p>

<p>I found out that when the facebook-connect is not working the first time, "onResume is called". The next time onActivityResult is called.</p>

<pre><code>@SuppressWarnings("deprecation")
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d("debug", "Main: onActivityResult");
    super.onActivityResult(requestCode, resultCode, data);

    facebook.authorizeCallback(requestCode, resultCode, data);
}
</code></pre>

<p>My login activity is an intent started by my main activity that is specifing if a login is needed at all:</p>

<pre><code>    Intent intent = new Intent(this, Login.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    startActivity(intent);
</code></pre>

<p>Sometimes I can see the following error:</p>

<pre><code>11-22 10:23:39.684: D/Facebook-publish(7317): Can NOT get FbInjector instance! Probably because this method was called in ContentProvider's onCreate.
</code></pre>
