private void onSessionStateChange(Session session, SessionState state, Exception exception) { if (state.isClosed()) { Log.i(logtaskact, "Logged out..."); Intent intent = new Intent(this, MainPage.class); this.startActivity(intent); } }
@SuppressWarnings("deprecation") private void onSessionStateChange(Session session, SessionState state, Exception exception) { if (session != currentSession) { return; } if (state.isOpened()) { // Log in just happened. // Toast.makeText(getApplicationContext(), "session opened", // Toast.LENGTH_SHORT).show(); System.out.println("Token=" + session.getAccessToken()); Request.executeMeRequestAsync( session, new GraphUserCallback() { @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { String[] separated; separated = user.toString().split("="); String json = separated[2]; Log.e("dfxfdsfsdf", user.toString()); Log.e("dfxfdsfsdf", json.toString()); try { // Facebook Profile JSON data JSONObject profile = new JSONObject(json); // getting name of the user fb_id = profile.getString("id"); Log.e("dfxfdsfsdf", fb_id.toString()); if (fb_id != null) { GlobalClaass.savePrefrencesfor(context, PreferenceConnector.Facebook_ID, fb_id); Log.e("First", "First"); login_type = "facebook"; CallFacebookLogin(login_type, fb_id, fb_id); } } catch (Exception e) { e.printStackTrace(); } } if (response != null) { /*System.out.println("Response=" + response); Toast.makeText(context, response.toString(), Toast.LENGTH_LONG).show();*/ } } }); } else if (state.isClosed()) { // Log out just happened. Update the UI. /*Toast.makeText(getApplicationContext(), "session closed", Toast.LENGTH_SHORT).show();*/ } }
@Override public void call(Session session, SessionState state, Exception exception) { if (state.isOpened()) { Log.d("FacebookSampleActivity", "Facebook session opened"); } else if (state.isClosed()) { Log.d("FacebookSampleActivity", "Facebook session closed"); } }
private void onSessionStateChange(Session session, SessionState state, Exception exception) { if (state.isOpened()) { Log.i(TAG, "Logged in..."); // Display authenticated UI here, e.g. making a new button visible } else if (state.isClosed()) { Log.i(TAG, "Logged out..."); // Display non-authenticated UI here, e.g. hiding the new button } }
// facebook private void onSessionStateChange(Session session, SessionState state, Exception exception) { if (state.isOpened()) { // Intent i = new Intent(LoginActivity.this, NavigationActivity.class); // Intent i = new Intent(LoginActivity.this, GoogleMapActivity.class); // startActivity(i); finish(); } else if (state.isClosed()) { // Toast.makeText(this, "Login failed! Please try again.", Toast.LENGTH_SHORT).show(); } }
public void onSessionStateChange(Session session, SessionState state, Exception exception) { if (state.isOpened()) { requestUserData(session); } else if (state.isClosed()) { mUserHelper.setCurrentUser(null); if (mStatusCallback != null) { mStatusCallback.onFacebookSessionClose(); } } }
public void call(Session session, SessionState sessionstate, Exception exception) { if (wrapped != null && isTracking()) { wrapped.wrapped(session, sessionstate, exception); } if (session == SessionTracker.access$200(SessionTracker.this) && sessionstate.isClosed()) { setSession(null); } }
@Override public void call(Session session, SessionState state, Exception exception) { if (state.isOpened()) { if (getCount() > 0) return; Request friendRequest = Request.newMyFriendsRequest( Session.getActiveSession(), new GraphUserListCallback() { @Override public void onCompleted(List<GraphUser> users, Response response) { if (getCount() > 0) return; if (users != null) { for (GraphUser graphUser : users) { ContentValues values = new ContentValues(); JSONObject userJson = graphUser.getInnerJSONObject(); if (userJson != null) { JSONObject pictureJson = userJson.optJSONObject("picture"); if (pictureJson != null) { JSONObject dataPictureJson = pictureJson.optJSONObject("data"); if (dataPictureJson != null) values.put( DBHelper.KEY_COLUMN_PICTURE, dataPictureJson.optString("url")); } } values.put(DBHelper.KEY_COLUMN_ID, graphUser.getId()); values.put( DBHelper.KEY_COLUMN_NAME, graphUser.getFirstName() + " " + graphUser.getLastName()); getActivity() .getContentResolver() .insert(DBProvider.CONTENT_DATA_URI, values); } } } }); Bundle params = new Bundle(); params.putString("fields", "id, first_name, last_name, picture.type(large)"); friendRequest.setParameters(params); friendRequest.executeAsync(); } else if (state.isClosed()) { } }
private void onSessionStateChange(Session session, SessionState state, Exception exception) { // Only make changes if the activity is visible if (state.isClosed()) { // If the session state is closed: // Show the login fragment Session.getActiveSession().closeAndClearTokenInformation(); Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); // showFragment(SPLASH, false); } }
private void onSessionStateChange(Session session, SessionState state, Exception exception) { if (isResumed) { FragmentManager manager = getSupportFragmentManager(); int backStackSize = manager.getBackStackEntryCount(); for (int i = 0; i < backStackSize; i++) { manager.popBackStack(); } if (state.isOpened()) { showFragment(SELECTION, false); } else if (state.isClosed()) { showFragment(SPLASH, false); } } }
private void onSessionStateChange(Session session, SessionState state, Exception exception) { if (state.isOpened()) { Log.i(TAG, "Logged in..."); // Check for publish permissions List<String> permissions = session.getPermissions(); if (!isSubsetOf(PERMISSIONS, permissions)) { Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS); session.requestNewPublishPermissions(newPermissionsRequest); return; } } else if (state.isClosed()) { Log.i(TAG, "Logged out..."); } }
private void onSessionStateChange(SessionState state) { if (isResumed && !isFinishing()) { if (state.isOpened()) { Globals.bProfileLoaded = true; Intent i = new Intent(this, MainActivity.class); i.putExtra(Globals.DONT_BACK_KEY, true); startActivityForResult(i, 0); finish(); Log.i(Globals.LOGIN_TAG, "Logged in..."); } else if (state.isClosed()) { Globals.bProfileLoaded = false; Log.i(Globals.LOGIN_TAG, "Logged out..."); } } }
private void onSessionStateChange(Session session, SessionState state, Exception exception) { Log.d(TAG, "onSessionStateChange!"); if (isResumed) { Log.d(TAG, "is resumed!"); FragmentManager manager = getSupportFragmentManager(); int backStackSize = manager.getBackStackEntryCount(); for (int i = 0; i < backStackSize; i++) { manager.popBackStack(); } // check for the OPENED state instead of session.isOpened() since for the // OPENED_TOKEN_UPDATED state, the selection fragment should already be showing. if (state.equals(SessionState.OPENED)) { Log.d(TAG, "onSessionStateChange: Logged to facebook"); Intent i = new Intent(LoginActivity.this, MainActivity.class); startActivityForResult(i, REQUEST_CODE_FACEBOOK_LOGIN); } else if (state.isClosed()) { // NO logged to facebook Log.d(TAG, "onSessionStateChange: Not logged to facebook"); } } }
private void onSessionStateChange(Session session, SessionState state, Exception exception) { if (state.isOpened() && !mIsGettingUserInfo) { mIsGettingUserInfo = true; Request.newMeRequest( session, new Request.GraphUserCallback() { @Override public void onCompleted(GraphUser graphUser, Response response) { User user = new User(); user.id = graphUser.getId(); user.fullName = graphUser.getName(); user.persist(getActivity()); BusProvider.getInstance().post(new LoginCompleteEvent()); Logger.l("Logged in..."); mIsGettingUserInfo = false; } }) .executeAsync(); } else if (state.isClosed()) { Logger.l("Logged out..."); } }
// <editor-fold desc="Facebook Methods"> private void onSessionStateChange(Session session, SessionState state, Exception exception) { if (isResumed) { // check for the OPENED state instead of session.isOpened() since for the // OPENED_TOKEN_UPDATED state, the selection fragment should already be showing. if (state.equals(SessionState.OPENED)) { if (registered) sendAccessTokenToBackend(session.getAccessToken()); Request.executeMeRequestAsync( session, new Request.GraphUserCallback() { @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { Log.i("FB User Id ", user.getId()); PreferenceManager.getDefaultSharedPreferences(a) .edit() .putInt("login_method", FACEBOOK_LOGIN) .commit(); setContentView(R.layout.activity_start); // LoadData(); Session session = Session.getActiveSession(); if (session != null && session.isOpened()) makeMeRequest(session); } } }); } else if (state.isClosed()) { PreferenceManager.getDefaultSharedPreferences(a) .edit() .putInt("login_method", NO_METHOD_DEFINED) .commit(); setContentView(R.layout.activity_login_only_facebook); } } }
private void onSessionStateChange(Session session, SessionState state, Exception exception) { if (state.isOpened()) { } else if (state.isClosed()) { } }