@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCallbackManager = CallbackManager.Factory.create(); shareDialog = new ShareDialog(this); shareDialog.registerCallback(mCallbackManager, mCallback); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); callbackManager = CallbackManager.Factory.create(); mtTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged( AccessToken oldAccessToken, AccessToken currentAccessToken) { Log.v( "AccessTokenTracker", "oldAccessToken=" + oldAccessToken + "||" + "CurrentAccessToken" + currentAccessToken); } }; mProfileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { Log.v( "Session Tracker", "oldProfile=" + oldProfile + "||" + "currentProfile" + currentProfile); homeFragment(currentProfile); } }; mtTracker.startTracking(); mProfileTracker.startTracking(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getActivity().getApplicationContext()); callbackManager = CallbackManager.Factory.create(); dbhandler = new databaseHandler(getActivity().getApplicationContext(), "SQLite", null, 1); database = dbhandler.getWritableDatabase(); accessTokenTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged(AccessToken oldToken, AccessToken newToken) {} }; profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile newProfile) { if (newProfile != null) { name = newProfile.getName(); displayMessage(name); } } }; accessTokenTracker.startTracking(); profileTracker.startTracking(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); Firebase.setAndroidContext(this); setContentView(R.layout.activity_main); ref = new Firebase("https://amber-fire-4138.firebaseio.com"); callbackManager = CallbackManager.Factory.create(); setContentView(R.layout.activity_main); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { onFacebookAccessTokenChange(loginResult.getAccessToken()); // App code } @Override public void onCancel() { // App code } @Override public void onError(FacebookException exception) { // App code } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance() .registerCallback( mCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { handlePedingAcction(); } @Override public void onCancel() {} @Override public void onError(FacebookException error) { Log.d("PostToSocialActivity", error.getMessage()); } }); mShareDialog = new ShareDialog(this); mShareDialog.registerCallback(mCallbackManager, shareCallback); mProfileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { handlePedingAcction(); } }; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize the SDK of FB and constructing the callbackmanager FacebookSdk.sdkInitialize(getActivity().getApplicationContext()); mCallbackManager = CallbackManager.Factory.create(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); callbackManager = CallbackManager.Factory.create(); setContentView(R.layout.activity_share_text); init(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); callbackManager = CallbackManager.Factory.create(); setContentView(R.layout.activity_main); info = (TextView) findViewById(R.id.info); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { info.setText( "User ID: " + loginResult.getAccessToken().getUserId() + "\n" + "Auth Token: " + loginResult.getAccessToken().getToken()); } @Override public void onCancel() { info.setText("Login attempt canceled."); } @Override public void onError(FacebookException error) { info.setText("Login attempt failed."); } }); }
public void onResume() { super.onResume(); // Load layout btnLogin = (LoginButton) findViewById(R.id.btnLogin); // Check if user is already logged in to Facebook with this app if (FacebookController.getInstance(this).isLoggedIn()) { writeProfileToPrefs(Profile.getCurrentProfile()); onLoginSuccessful(); } callbackManager = CallbackManager.Factory.create(); btnLogin.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { writeProfileToPrefs(Profile.getCurrentProfile()); onLoginSuccessful(); } @Override public void onCancel() { Toast.makeText(LoginActivity.this, R.string.login_cancelled, Toast.LENGTH_LONG).show(); } @Override public void onError(FacebookException exception) { Toast.makeText(LoginActivity.this, R.string.login_failed, Toast.LENGTH_LONG).show(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); setContentView(R.layout.activity_login); SignInButton button = (SignInButton) findViewById(R.id.google_login); button.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { pickUserAccount(); } }); callbackManager = CallbackManager.Factory.create(); fbButton = (LoginButton) findViewById(R.id.facebook_login); fbButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d("LoginActivity", loginResult.getAccessToken().getToken()); mBoundService.sendJOIN("fb", loginResult.getAccessToken().getToken()); } @Override public void onCancel() {} @Override public void onError(FacebookException error) {} }); }
private void facebookLogin() { Log.d("TarotFeedback", "facebookLogin called"); facebookCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance() .registerCallback( facebookCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d("TarotFeedback", loginResult.getAccessToken().getUserId()); Log.d("TarotFeedback", loginResult.getAccessToken().getApplicationId()); Log.d("TarotFeedback", loginResult.getAccessToken().getToken()); getUserDetails(loginResult.getAccessToken()); } @Override public void onCancel() { Log.d("TarotFeedback", "User cancelled"); } @Override public void onError(FacebookException error) { Log.d("TarotFeedback", "Error " + error.toString()); } }); List<String> permissions = Arrays.asList("public_profile", "email"); LoginManager.getInstance().logInWithReadPermissions(this, permissions); }
private void onFblogin() { callbackmanager = CallbackManager.Factory.create(); LoginManager.getInstance() .logInWithReadPermissions( this, Arrays.asList("user_photos", "user_posts", "user_friends", "public_profile")); LoginManager.getInstance() .registerCallback( callbackmanager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { System.out.println("Success"); contentButton.setVisibility(View.GONE); access_token = AccessToken.getCurrentAccessToken(); getFacebookData(); } @Override public void onCancel() { System.out.println("On cancel"); } @Override public void onError(FacebookException e) { System.out.println(e.toString()); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(this); setContentView(R.layout.activity_log_in); // setViewObject(); // setListner(); callbackManager = CallbackManager.Factory.create(); // LoginButtonはFacebookSDKに含まれたButtonウィジェットの拡張ウィジェット。 loginButton = (LoginButton) findViewById(R.id.login_btn_facebook); // APIから取得したいユーザー情報の種類を指定し、パーミッションを許可する。 List<String> permissionNeeds = Arrays.asList("user_photos", "email", "user_birthday", "public_profile"); loginButton.setReadPermissions(permissionNeeds); loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { System.out.println(""); GraphRequest request = GraphRequest.newMeRequest( loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject object, GraphResponse response) { // API連携に成功し、ログイン状態になったら、下記のようなゲッター関数により、ユーザー情報を取得することが出来る。 try { String id = object.getString("id"); String name = object.getString("name"); String email = object.getString("email"); String gender = object.getString("gender"); String birthday = object.getString("birthday"); System.out.println(name); } catch (JSONException e) { e.printStackTrace(); } } }); Bundle parameters = new Bundle(); parameters.putString("fields", "id,name,email,gender, birthday"); request.setParameters(parameters); request.executeAsync(); } @Override public void onCancel() { System.out.println("onCancel"); } @Override public void onError(FacebookException exception) { Log.v("LoginActivity", exception.toString()); } }); }
protected void onSignUp() { changeCurrentState(StatusFacebookConn.CONNECTING); Log.i(TAGINFO, "Connecting"); callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, this); LoginManager.getInstance() .logInWithReadPermissions(activityWeakReference.get(), facebookPermissions); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_capture); CalligraphyConfig.initDefault( new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf") .setFontAttrId(R.attr.fontPath) .build()); ButterKnife.bind(this); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setNavigationIcon(R.drawable.icn_back); title.setText("COLLECTIONS"); FacebookSdk.sdkInitialize(this); callbackManager = CallbackManager.Factory.create(); shareDialog = new ShareDialog(this); // this part is optional shareDialog.registerCallback( callbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { if (result.getPostId() != null) { Toast.makeText(getBaseContext(), "Success", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getBaseContext(), "Problem posting story", Toast.LENGTH_SHORT).show(); } } @Override public void onCancel() { Toast.makeText(getBaseContext(), "Cancelled", Toast.LENGTH_SHORT).show(); } @Override public void onError(FacebookException e) { Toast.makeText(getBaseContext(), "Error sharing", Toast.LENGTH_SHORT).show(); } }); song_name.setText(getIntent().getStringExtra("title").toUpperCase()); Picasso.with(getBaseContext()) .load(getIntent().getStringExtra("image_link")) .placeholder(R.drawable.speaker_icn1) .into(album_art); note.setText(getIntent().getStringExtra("note")); playlist.setText(Html.fromHtml("or <u>Add to Playlist</u>")); }
private void initFacebook() { // Initialize the SDK before executing any other operations, // especially, if you're using Facebook UI elements. FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create(); shareDialog = new ShareDialog(this); // You need this method to be used only once to configure // your key hash in your App Console at // developers.facebook.com/apps Utils utils = new Utils(this); utils.getFbKeyHash(getApplicationContext().getPackageName()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_payment); mActivity = this; FacebookSdk.sdkInitialize(mActivity.getApplicationContext()); callbackManager = CallbackManager.Factory.create(); setupToolBar(); getIntentExtras(); populateUI(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.facebook_login); // Initialise facebook SDK FacebookSdk.sdkInitialize(getApplicationContext()); mCallbackManager = CallbackManager.Factory.create(); mCircularImageView = (CircularImageView) findViewById(R.id.imageView); txtName = (TextView) findViewById(R.id.txt_name); // txtDOB = (TextView) findViewById(R.id.txt_dob); txtName.setText("this is sample text"); mLoginButton = (LoginButton) findViewById(R.id.login_button); mLoginButton.setReadPermissions("user_friends"); LoginManager.getInstance() .registerCallback( mCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { updateUI(); } @Override public void onCancel() { Log.v(logString, "Login cancle"); } @Override public void onError(FacebookException error) { Log.e(logString, "error"); error.printStackTrace(); } }); profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { Log.v(logString, "onCurrentProfileTracker"); updateUI(); } }; // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getActivity().getApplicationContext()); prefFile = getActivity().getResources().getString(R.string.tlpSharedPreference); callbackManager = CallbackManager.Factory.create(); // setupProfileTracker(); setupTokenTracker(); mTokenTracker.startTracking(); // mProfileTracker.startTracking(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // initializing facebook sdk FacebookSdk.sdkInitialize(getApplicationContext()); // setting layout setContentView(R.layout.activity_login); // binding id's to view ButterKnife.bind(this); // facebook login button fbLoginButton.setReadPermissions("user_friends", "public_profile"); // initializing callback function callbackManager = CallbackManager.Factory.create(); // Callback registration fbLoginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { // App code // getUserDetail(); // Intent goToNavigation = new Intent(LoginActivity.this, // NavigationDrawerActivity.class); } @Override public void onCancel() { Snackbar.make( fbLoginButton, "Can not login using Facebook, Please try logging again or Enter application without logging in", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } @Override public void onError(FacebookException exception) { Snackbar.make(fbLoginButton, "Some Error occurred! Login again", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); setContentView(R.layout.activity_log_in); callbackManager = CallbackManager.Factory.create(); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d("debug", loginResult.getAccessToken().getToken()); AccessToken accessToken = loginResult.getAccessToken(); GraphRequest.newMeRequest( accessToken, new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject jsonObject, GraphResponse graphResponse) { Log.d("debug", "me request: " + jsonObject.toString()); } }) .executeAsync(); GraphRequest.newGraphPathRequest( accessToken, "/me?fields=feed", new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse graphResponse) { String response = graphResponse.getRawResponse(); Log.d("debug", "graph path request: " + response); } }) .executeAsync(); } @Override public void onCancel() {} @Override public void onError(FacebookException e) { e.printStackTrace(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Iniciar Parse Parse.initialize( this, getResources().getString(R.string.parseId), getResources().getString(R.string.parseKey)); localRepository = new ParseLocalRepository(); camareroRepository = new ParseCamareroRepository(); cocinaRepository = new ParseCocinaRepository(); extraRepository = new ParseExtraRepository(); // iniciar Facebook FacebookSdk.sdkInitialize(getApplicationContext()); // Hay que cargar la api de facebook antes de ejecutar el setContextView para que importe el // boton estilo facebook setContentView(R.layout.activity_main); callbackManager = CallbackManager.Factory.create(); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { user = new Usuario(loginResult.getAccessToken().getUserId()); AccessToken accessToken = loginResult.getAccessToken(); profile = Profile.getCurrentProfile(); } @Override public void onCancel() { Toast.makeText(getBaseContext(), "Inicio de sesion cancelado", Toast.LENGTH_SHORT) .show(); } @Override public void onError(FacebookException e) { Toast.makeText(getBaseContext(), "Inicio de sesion fallido", Toast.LENGTH_SHORT).show(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(this.getApplicationContext()); requestWindowFeature(Window.FEATURE_NO_TITLE); // hide title getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // hide top bar setContentView(R.layout.highscorescreen); btn_back = (Button) findViewById(R.id.btn_back); btn_back.setOnClickListener(this); theScore = getSharedPreferences("thePref", Context.MODE_PRIVATE); theText = (TextView) findViewById(R.id.textView); theText.setText("" + theScore.getInt("HighScore", 0)); callbackManager = CallbackManager.Factory.create(); List<String> PERMISSIONS = Arrays.asList("publish_actions"); loginBtn = (LoginButton) findViewById(R.id.fb_login_button); loginManager = LoginManager.getInstance(); loginManager.logInWithPublishPermissions(this, PERMISSIONS); loginBtn.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { sharePhotoToFacebook(); } @Override public void onCancel() { userName.setText("Login attempt canceled."); } @Override public void onError(FacebookException e) { userName.setText("Login attempt failed."); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build(); mClient.connect(); Intent sIntent = new Intent(this, BeeplePaperService.class); startService(sIntent); FacebookSdk.sdkInitialize(getApplicationContext()); setContentView(R.layout.activity_main); final Button btn = (Button) findViewById(R.id.mButt); btn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent mIntent = new Intent(Intent.ACTION_SEND); sendBroadcast(mIntent); } }); callbackManager = CallbackManager.Factory.create(); Log.d(TAG, "Building login button for FB"); LoginButton loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setReadPermissions("user_friends"); loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d(TAG, "Getting access token"); } @Override public void onCancel() { Log.d(TAG, "Login Cancelled"); } @Override public void onError(FacebookException exception) { Log.e(TAG, exception.toString()); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); setContentView(R.layout.activity_login); callbackManager = CallbackManager.Factory.create(); googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN) .build(); LoginButton loginButton = (LoginButton) findViewById(R.id.activity_login_facebook); googleSignIn = (SignInButton) findViewById(R.id.activity_login_google); getToken = (Button) findViewById(R.id.activity_login_auth_token); loginButton.setReadPermissions("email"); facebookTokenTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged( AccessToken oldAccessToken, AccessToken newAccessToken) { isFbLogin = true; Toast.makeText(LoginActivity.this, "Facebook Access Token", Toast.LENGTH_SHORT).show(); } }; facebookProfileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile newProfile) { isFbLogin = (!isFbLogin); Toast.makeText(LoginActivity.this, "Facebook Current Profile", Toast.LENGTH_SHORT) .show(); } }; facebookTokenTracker.startTracking(); facebookProfileTracker.startTracking(); googleSignIn.setOnClickListener(this); getToken.setOnClickListener(this); }
/** {@inheritDoc} */ @Override public void initializeSignInButton( final Activity signInActivity, final View buttonView, final IdentityManager.SignInResultsHandler resultsHandler) { FacebookSdk.sdkInitialize(signInActivity); if (buttonView == null) { throw new IllegalArgumentException("Facebook login button view not passed in."); } facebookCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance() .registerCallback( facebookCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d(LOG_TAG, "Facebook provider sign-in succeeded."); resultsHandler.onSuccess(FacebookSignInProvider.this); } @Override public void onCancel() { Log.d(LOG_TAG, "Facebook provider sign-in canceled."); resultsHandler.onCancel(FacebookSignInProvider.this); } @Override public void onError(FacebookException exception) { Log.e(LOG_TAG, "Facebook provider sign-in error: " + exception.getMessage()); resultsHandler.onError(FacebookSignInProvider.this, exception); } }); buttonView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { LoginManager.getInstance() .logInWithReadPermissions(signInActivity, Arrays.asList("public_profile")); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); setContentView(R.layout.activity_login); callbackManager = CallbackManager.Factory.create(); LoginButton loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setReadPermissions("public_profile"); // Callback registration loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { updateDatabase(); // jump to another activity Intent showPosts = new Intent(LoginActivity.this, PostActivity.class); startActivity(showPosts); } @Override public void onCancel() { showAlert(); } @Override public void onError(FacebookException exception) { showAlert(); } private void showAlert() { new AlertDialog.Builder(LoginActivity.this) .setTitle(R.string.cancelled) .setMessage(R.string.login_failed) .setPositiveButton(R.string.ok, null) .show(); } }); LoginManager.getInstance() .logInWithReadPermissions(this, Collections.singletonList("public_profile")); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); if (this.isLogeedIn()) { goToMain(); return; } this.mFacebookLogin = (LoginButton) this.findViewById(R.id.facebook_login_button); // Add Facebook read permission this.mFacebookLogin.setReadPermissions(LoginActivity.FACEBOOK_READ_PERMISSION); // Facebook Callback registration this.mFacebookCallbackManager = CallbackManager.Factory.create(); this.mFacebookLogin.registerCallback(this.mFacebookCallbackManager, this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); setContentView(R.layout.activity_main); callbackManager = CallbackManager.Factory.create(); final LoginButton loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setReadPermissions("public_profile", "email", "user_friends"); loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Intent intent = new Intent(MainActivity.this, HomeActivity.class); startActivity(intent); System.out.print("Logged in"); } @Override public void onCancel() { // App code } @Override public void onError(FacebookException exception) { Toast.makeText( MainActivity.this, "Error al realizar Login Facebook", Toast.LENGTH_SHORT) .show(); Log.i("Error", "Error"); } }); // printHashKey(); }
public void onFacebookLogin() { callbackManager = CallbackManager.Factory.create(); ArrayList<String> permissions = new ArrayList<>(); permissions.add(PERMIT); LoginManager.getInstance().logInWithReadPermissions(this, permissions); LoginManager.getInstance() .registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { AccessToken accessToken = loginResult.getAccessToken(); Profile profile = Profile.getCurrentProfile(); if (profile != null) { verifyFbProfile(profile); } ProfileTracker profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged( Profile profile, Profile currentProfile) { Profile.setCurrentProfile(currentProfile); verifyFbProfile(currentProfile); this.stopTracking(); } }; profileTracker.startTracking(); finish(); } @Override public void onCancel() { finish(); } @Override public void onError(FacebookException e) { Log.d(TAG, e.toString()); } }); }