Java Code Examples for com.facebook.Session#openActiveSessionFromCache()
The following examples show how to use
com.facebook.Session#openActiveSessionFromCache() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginButton.java From Klyph with MIT License | 6 votes |
private boolean initializeActiveSessionWithCachedToken(Context context) { if (context == null) { return false; } Session session = Session.getActiveSession(); if (session != null) { return session.isOpened(); } String applicationId = Utility.getMetadataApplicationId(context); if (applicationId == null) { return false; } return Session.openActiveSessionFromCache(context) != null; }
Example 2
Source File: LoginButton.java From KlyphMessenger with MIT License | 6 votes |
private boolean initializeActiveSessionWithCachedToken(Context context) { if (context == null) { return false; } Session session = Session.getActiveSession(); if (session != null) { return session.isOpened(); } String applicationId = Utility.getMetadataApplicationId(context); if (applicationId == null) { return false; } return Session.openActiveSessionFromCache(context) != null; }
Example 3
Source File: TitledActivity.java From Klyph with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { setTheme(getCustomTheme()); KlyphLocale.defineLocale(getBaseContext()); super.onCreate(savedInstanceState); userHasDonated = KlyphPreferences.hasUserDonated(); setContentView(getLayout()); KlyphDevice.initDeviceValues(this); setAppIconBackToHomeEnabled(true); displayBackArrow(true); // manageAdView((AdView) findViewById(R.id.ad), LFPA.FREE_VERSION); if (!KlyphSession.isLogged()) { logout(); } else if (Session.getActiveSession() == null) { Session.openActiveSessionFromCache(this); } }
Example 4
Source File: BirthdayService.java From Klyph with MIT License | 5 votes |
private void launchRequest() { if (service.get() == null) return; Service s = service.get(); if (Session.getActiveSession() == null) { try { Session.openActiveSessionFromCache(s); } catch (UnsupportedOperationException e) { Log.e("BirthdayService", e.getMessage()); } } AsyncRequest request = new AsyncRequest(Query.BIRTHDAY_NOTIFICATIONS, "", "", new AsyncRequest.Callback() { @Override public void onComplete(Response response) { if (response.getError() == null) { onRequestSuccess(response.getGraphObjectList()); } else { Log.d("BirthdayService", "onError " + response.getError()); if (service.get() != null) service.get().stopSelf(); } } }); request.execute(); }
Example 5
Source File: TitledActivity.java From KlyphMessenger with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { KlyphLocale.defineLocale(getBaseContext()); super.onCreate(savedInstanceState); getActionBar().setIcon(R.drawable.ic_ab_launcher); setContentView(getLayout()); KlyphDevice.initDeviceValues(this); setAppIconBackToHomeEnabled(true); displayBackArrow(true); // manageAdView((AdView) findViewById(R.id.ad), LFPA.FREE_VERSION); if (!KlyphSession.isLogged()) { logout(); } else if (Session.getActiveSession() == null) { Session.openActiveSessionFromCache(this); } }
Example 6
Source File: TitledFragmentActivity.java From KlyphMessenger with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { KlyphLocale.defineLocale(getBaseContext()); super.onCreate(savedInstanceState); currentTheme = getCustomTheme(); currentLocale = KlyphLocale.getDeviceLocale(); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); //getActionBar().setIcon(R.drawable.ic_ab_launcher); KlyphDevice.initDeviceValues(this); if (!(this instanceof MainActivity)) { setAppIconBackToHomeEnabled(true); //displayBackArrow(true); } else { setAppIconBackToHomeEnabled(false); } /* * getActionBar().setStackedBackgroundDrawable( * getResources().getDrawable( * R.drawable.stacked_transparent_light_holo)); */ //enableAds(true); if (Session.getActiveSession() == null) { Session.openActiveSessionFromCache(this); } }
Example 7
Source File: StreamActivity.java From Klyph with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { Log.d("StreamActivity", "onCreate: "); super.onCreate(savedInstanceState); Log.d("StreamActivity", "onCreate: 2"); // Let the Application class know that the first launch is complete // If we come from a notification, then do not show the ads // When going back to main activity KlyphApplication.getInstance().launchComplete(); if (Session.getActiveSession() == null) { Log.d("StreamActivity", "Session is null "); Session.openActiveSessionFromCache(this); } StreamFragment streamFragment = (StreamFragment) getFragmentManager().findFragmentById(R.id.stream_fragment); // setTitle("Messages"); Stream stream = getIntent().getParcelableExtra(KlyphBundleExtras.STREAM_PARCELABLE); if (stream != null) { Log.d("StreamActivity", "setStreamAndLoad "); streamFragment.setStreamAndLoad(stream); } else { Log.d("StreamAct", "Received id " + getIntent().getStringExtra(KlyphBundleExtras.STREAM_ID) + " " + getIntent().getBooleanExtra(KlyphBundleExtras.STREAM_GROUP, false)); streamFragment.setElementId(getIntent().getStringExtra(KlyphBundleExtras.STREAM_ID)); if (getIntent().getBooleanExtra(KlyphBundleExtras.STREAM_GROUP, false) == true) { Log.d("StreamAct", "is group "); streamFragment.setIsStreamGroup(); } Log.d("StreamActivity", "load "); streamFragment.load(); } }
Example 8
Source File: TitledFragmentActivity.java From Klyph with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { setTheme(getCustomTheme()); KlyphLocale.defineLocale(getBaseContext()); super.onCreate(savedInstanceState); currentTheme = getCustomTheme(); currentLocale = KlyphLocale.getDeviceLocale(); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); KlyphDevice.initDeviceValues(this); userHasDonated = KlyphPreferences.hasUserDonated(); if (!(this instanceof MainActivity)) { setAppIconBackToHomeEnabled(true); displayBackArrow(true); } else { setAppIconBackToHomeEnabled(false); } /* * getSupportActionBar().setStackedBackgroundDrawable( * getResources().getDrawable( * R.drawable.stacked_transparent_light_holo)); */ //enableAds(true); if (!KlyphSession.isLogged()) { if (!(this instanceof MainActivity)) logout(); } else if (Session.getActiveSession() == null) { Session.openActiveSessionFromCache(this); } if (getIntent().getBooleanExtra(KlyphBundleExtras.SET_NOTIFICATION_AS_READ, false) == true) { String id = getIntent().getStringExtra(KlyphBundleExtras.NOTIFICATION_ID); if (id != null && id.length() > 0) { new AsyncRequest(Query.POST_READ_NOTIFICATION, id, "", null).execute(); } } }
Example 9
Source File: NotificationService.java From Klyph with MIT License | 4 votes |
private void launchRequest() { Log.d("NotificationService.ServiceHandler", "launchRequest: "); if (service.get() == null) return; try { if (Session.getActiveSession() == null) { Session.openActiveSessionFromCache(service.get()); } } catch (UnsupportedOperationException e) { Log.d("NotificationService.ServiceHandler", "launchRequest: exception " + e.getMessage()); } if (Session.getActiveSession() != null && Session.getActiveSession().getPermissions().contains("manage_notifications")) { AsyncRequest request = new AsyncRequest(Query.PERIODIC_NOTIFICATIONS, "me()", /*KlyphPreferences.getNotificationServiceOffset()*/"", new AsyncRequest.Callback() { @Override public void onComplete(Response response) { if (response.getError() == null) { onRequestSuccess(response.getGraphObjectList()); } else { if (service.get() != null) service.get().stopSelf(); } } }); request.execute(); } else { if (service.get() != null) service.get().stopSelf(); } }
Example 10
Source File: FriendRequestService.java From Klyph with MIT License | 4 votes |
private void launchRequest() { if (service.get() == null) return; Service s = service.get(); if (Session.getActiveSession() == null) { try { Session.openActiveSessionFromCache(s); } catch (UnsupportedOperationException e) { } } if (Session.getActiveSession() != null) { AsyncRequest request = new AsyncRequest(Query.FRIEND_REQUEST_NOTIFICATION, KlyphPreferences.getNotificationServiceOffset(), KlyphPreferences.getFriendRequestServiceOffset(), new AsyncRequest.Callback() { @Override public void onComplete(Response response) { if (response.getError() == null) { onRequestSuccess(response.getGraphObjectList()); } else { if (service.get() != null) service.get().stopSelf(); } } }); request.execute(); } }
Example 11
Source File: SnakeGameActivity.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 4 votes |
private void logoutAndUnlink() { //logout/unlink and wipe local dataset //new CognitoUnlinkTask().execute(); Session session = Session.openActiveSessionFromCache(SnakeGameActivity.this); if (session != null) { session.closeAndClearTokenInformation(); } AmazonAuthorizationManager mAuthManager = new AmazonAuthorizationManager(this, Bundle.EMPTY); if (mAuthManager != null) { mAuthManager.clearAuthorizationState(null); } AWSClientManager.getCognitoSync().wipeData(); Toast.makeText(gameView.getContext(), "Logout Successful", Toast.LENGTH_SHORT).show(); }