Beispiel #1
0
  @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) {}
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    // Updated Facebook SDK from 3.7 to 4.1

    boolean showSplash =
        getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("isFirstRun", true);
    checkFirstRun();
    if (showSplash) {
      Intent intent = new Intent(getApplicationContext(), SplashActivity.class);
      startActivity(intent);
    }
    ;
    setContentView(R.layout.activity_map);
    buildGoogleApiClient();
    // Log.w("TAG", "Play services configured: " + Boolean.toString(isPlayServicesConfigured()));
    try {
      MapsInitializer.initialize(this);
    } catch (Exception e) {
      Toast.makeText(
              this,
              "Ensure that Google Play Services is properly installed and updated, or this app will continue to crash.",
              Toast.LENGTH_LONG)
          .show();
    }
    setUpMapIfNeeded();
    getActionBar().setDisplayHomeAsUpEnabled(false); // necessary to declare false
    mMap.moveCamera(
        CameraUpdateFactory.newLatLngZoom(
            new LatLng(39.952595, -75.163736),
            13)); // Town Center Philadelphia, zoom = 13. Bigger # = more zoomed in
  }
Beispiel #3
0
  @Override
  public void onCreate() {
    super.onCreate();
    mInstance = this;

    AnalyticsTrackers.initialize(this);
    AnalyticsTrackers.getInstance().get(AnalyticsTrackers.Target.APP);

    /*facebook*/
    FacebookSdk.sdkInitialize(getApplicationContext());
    try {
      PackageInfo info =
          getPackageManager()
              .getPackageInfo(
                  "com.jukesolutions.olahdana", // replace with your unique package name
                  PackageManager.GET_SIGNATURES);
      for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
      }
    } catch (PackageManager.NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }
  }
Beispiel #4
0
 @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();
 }
  @UnityCallable
  public static void Init(final String params_str) {
    Log.v(TAG, "Init(" + params_str + ")");
    UnityParams unity_params =
        UnityParams.parse(params_str, "couldn't parse init params: " + params_str);
    final String appID;
    if (unity_params.hasString("appId")) {
      appID = unity_params.getString("appId");
    } else {
      appID = Utility.getMetadataApplicationId(getUnityActivity());
    }

    FacebookSdk.setApplicationId(appID);
    FacebookSdk.sdkInitialize(
        FB.getUnityActivity(),
        new FacebookSdk.InitializeCallback() {
          @Override
          public void onInitialized() {
            final UnityMessage unityMessage = new UnityMessage("OnInitComplete");
            // If we have a cached access token send it back as well
            AccessToken token = AccessToken.getCurrentAccessToken();
            if (token != null) {
              FBLogin.addLoginParametersToMessage(unityMessage, token, null);
            } else {
              unityMessage.put("key_hash", FB.getKeyHash());
            }

            FB.ActivateApp(appID);

            unityMessage.send();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    // Mint.initAndStartSession(SplashScreenActivity.this, "0b8079db");
    FacebookSdk.sdkInitialize(getApplicationContext());
    imgLogo = (ImageView) findViewById(R.id.imgLogo);

    final float scale = getResources().getDisplayMetrics().density;
    wH_logo = (int) (200 * scale + 0.5f);

    gps = new ConfigInternetAndGPS(getApplicationContext());

    // Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.dheket);
    // url = String.format(getResources().getString(R.string.link_cekUserLogin));

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {
                showAlertGPS();
                /*Intent intentRedirectionGPSSettings = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                intentRedirectionGPSSettings.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                startActivityForResult(intentRedirectionGPSSettings, 0);*/
              }
            },
            SPLASH_TIME_OUT);
  }
 private FacebookAccountConnection(Activity activity) {
   changeCurrentState(StatusFacebookConn.DISCONNECTED);
   Log.i(TAGINFO, "Initializing/Disconnected");
   activityWeakReference = new WeakReference<>(activity);
   FacebookSdk.sdkInitialize(activity);
   FacebookSdk.setApplicationId(APIID);
 }
  @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
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());

    setContentView(R.layout.activity_main);
    nameText = (TextView) findViewById(R.id.text_name);
    dataList = (ListView) findViewById(R.id.list_data);
    contentButton = (Button) findViewById(R.id.content_button);
    fbbutton = (LoginButton) findViewById(R.id.login_button);

    fbbutton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onFblogin();
          }
        });
    if (AccessToken.getCurrentAccessToken() != null) {
      contentButton.setVisibility(View.VISIBLE);
      contentButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              access_token = AccessToken.getCurrentAccessToken();
              getFacebookData();
            }
          });
    }
  }
  @Override
  public void onCreate() {
    super.onCreate();
    // Register your parse models here
    ParseObject.registerSubclass(Address.class);
    ParseObject.registerSubclass(Gym.class);
    ParseObject.registerSubclass(Message.class);
    ParseObject.registerSubclass(SimpleUser.class);
    ParseObject.registerSubclass(Trainer.class);
    ParseObject.registerSubclass(Review.class);
    ParseObject.registerSubclass(TrainerSlots.class);
    ParseObject.registerSubclass(BlockedSlots.class);
    Parse.enableLocalDatastore(this);
    Parse.initialize(this, APPLICATION_ID, CLIENT_KEY);

    ParsePush.subscribeInBackground(
        "",
        new SaveCallback() {
          @Override
          public void done(ParseException e) {
            if (e == null) {
              Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
              PushService.setDefaultPushCallback(
                  getBaseContext(),
                  ChatActivity.class); // change the class where u want to go after clicking on noti
              ParseInstallation.getCurrentInstallation().saveInBackground();
            } else {
              Log.e("com.parse.push", "failed to subscribe for push", e);
            }
          }
        });

    FacebookSdk.sdkInitialize(getApplicationContext());
  }
 @Override
 public void onCreate() {
   super.onCreate();
   FacebookSdk.sdkInitialize(getApplicationContext());
   configImageLoader();
   configParse();
 }
Beispiel #12
0
  @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();
  }
Beispiel #13
0
  public static String getMetadataApplicationId(Context context) {
    Validate.notNull(context, "context");

    FacebookSdk.sdkInitialize(context);

    return FacebookSdk.getApplicationId();
  }
  @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());
          }
        });
  }
  /**
   * Constuctor. Intitializes the SDK and debug logs the app KeyHash that must be set up with the
   * facebook backend to allow login from the app.
   *
   * @param context the context.
   */
  public FacebookSignInProvider(final Context context) {

    if (!FacebookSdk.isInitialized()) {
      Log.d(LOG_TAG, "Initializing Facebook SDK...");
      FacebookSdk.sdkInitialize(context);
      Utils.logKeyHash(context);
    }
  }
 @Override
 public void onCreate() {
   super.onCreate();
   app = this;
   Firebase.setAndroidContext(this);
   mFirebaseRef = new Firebase(this.getString(R.string.firebase_url));
   FacebookSdk.sdkInitialize(this);
 }
 @Override
 public void onCreate() {
   super.onCreate();
   Fabric.with(this, new Crashlytics());
   AppApi.createInstance(getApplicationContext());
   FacebookSdk.sdkInitialize(getApplicationContext());
   Fresco.initialize(this);
 }
 @Nullable
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   FacebookSdk.sdkInitialize(getContext());
   return inflater.inflate(R.layout.fragment_createuser, container, false);
 }
Beispiel #19
0
  @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>"));
  }
Beispiel #20
0
  private String getAccessToken() {

    FacebookSdk.sdkInitialize(StudentAssistApplication.getAppContext());

    if (AccessToken.getCurrentAccessToken() != null
        && !AccessToken.getCurrentAccessToken().isExpired()) {
      String fbToken = AccessToken.getCurrentAccessToken().getToken();
      return fbToken;
    }

    return "";
  }
  @Override
  public void onCreate() {
    super.onCreate();
    FacebookSdk.sdkInitialize(getApplicationContext());
    Firebase.setAndroidContext(this);
    Firebase.getDefaultConfig().setPersistenceEnabled(true);
    Firebase firebase = new Firebase(Constants.FIREBASE_REF);
    firebase.keepSynced(true);

    if (BuildConfig.DEBUG) {
      Timber.plant(new Timber.DebugTree());
    }
  }
  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
 public void onCreate() {
   super.onCreate();
   Parse.enableLocalDatastore(this);
   ParseObject.registerSubclass(Circle.class);
   ParseObject.registerSubclass(UserCircle.class);
   ParseObject.registerSubclass(Friend.class);
   FacebookSdk.sdkInitialize(getApplicationContext());
   Parse.initialize(
       this,
       "Bugsei9yjtBNjH51JSerSEniB895r1zLA3NwFDUO",
       "ilswrJMAc26LQCRptGaMn5XiH5uVTIHrkfLP82W3");
   ParseFacebookUtils.initialize(this);
 }
  @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();
  }
Beispiel #25
0
  @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);
    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);

    // 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();
          }
        });
  }
Beispiel #29
0
  @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);

    // 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();
          }
        });
  }