I have a problem with Facebook login on Android 2.3.3 (HTC Wildifre S). When I click on Login to Facebook button, it redirects me to Facebook app - I put there my login and password. Then I get redirected to web browser and I must login again on web page and then web browser redirects me to URL like fbconnect://success?access_token=xxxxxxxxxxxxx?expires_at=yyyyy. Web browser cannot handle this URL so I get page not found error and I'm not redirected to my app again.
I have Facebook App, I added package and class name in config, I have properly configured appId in my Android app and I generated key hash and put in my Facebook App config.
Strange thing is that it is working on Android 4.1 (Samsung Galaxy S Plus).
Here is code of my activity :
package com.example.apptest; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; import com.facebook.LoggingBehavior; import com.facebook.Session; import com.facebook.SessionState; import com.facebook.Settings; import com.facebook.android.Facebook; public class FBLogin extends Activity { public static final int GAME_THREAD_DELAY = 4000; //private static final String URL_PREFIX_FRIENDS = "https://graph.facebook.com/me/friends?access_token="; Facebook fb; SharedPreferences sp; private Button button_fblogin; private Session.StatusCallback statusCallback = new SessionStatusCallback(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fblogin); Toast.makeText(FBLogin.this, "onCreate", Toast.LENGTH_SHORT).show(); button_fblogin = (Button) findViewById(R.id.fblogin_btn); Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS); Session session = Session.getActiveSession(); if (session == null){ Toast.makeText(FBLogin.this, "session == null", Toast.LENGTH_SHORT).show(); if (savedInstanceState != null){ session = Session.restoreSession(this, null, statusCallback, savedInstanceState); } if (session == null){ Toast.makeText(FBLogin.this, "session= new Session()", Toast.LENGTH_SHORT).show(); session = new Session(this); } Session.setActiveSession(session); if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)){ session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback)); } } updateView(); } @Override public void onStart(){ super.onStart(); Session.getActiveSession().addCallback(statusCallback); } @Override public void onStop(){ super.onStop(); Session.getActiveSession().removeCallback(statusCallback); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); } private class SessionStatusCallback implements Session.StatusCallback { @Override public void call(Session session, SessionState state, Exception exception) { updateView(); } } private void updateView() { Toast.makeText(FBLogin.this, "updateView", Toast.LENGTH_SHORT).show(); Session session = Session.getActiveSession(); if (session.isOpened()) { button_fblogin.setText(R.string.button_fblogout); button_fblogin.setOnClickListener(new OnClickListener() { public void onClick(View view) { onClickLogout(); } }); } else { button_fblogin.setText(R.string.fblogin_button_title); button_fblogin.setOnClickListener(new OnClickListener() { public void onClick(View view) { onClickLogin(); } }); } } private void onClickLogin(){ Session session = Session.getActiveSession(); if (!session.isOpened() && !session.isClosed()){ session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback)); Toast.makeText(FBLogin.this, "onClickLogin", Toast.LENGTH_SHORT).show(); }else{ Session.openActiveSession(this, true, statusCallback); } } private void onClickLogout(){ Session session = Session.getActiveSession(); if (!session.isClosed()){ session.closeAndClearTokenInformation(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.fblogin, menu); return true; } }
Source: http://stackoverflow.com/questions/16790484/facebook-sdk-on-android-2-3-page-not-found
hocus pocus mta schedule PECO Hurricane Sandy update ellen degeneres tomb of the unknown soldier tomb of the unknown soldier
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.