@Override
 public void onResume() {
   super.onResume();
   // refresh login state when coming back to the fragment
   refreshLoginState();
   // if already loggedin we don't need to continue
   if (authenticating) {
     // The next part must be inserted in the onResume() method of the
     // fragment from which session.startAuthentication() was called, so
     // that Dropbox authentication completes properly.
     AndroidAuthSession session = mApi.getSession();
     if (session.authenticationSuccessful()) {
       authenticating = false;
       try {
         // Mandatory call to complete the auth
         session.finishAuthentication();
         // Store it locally in the app for later use
         TokenPair tokens = session.getAccessTokenPair();
         storeKeys(tokens.key, tokens.secret);
         // set the preference flag
         setLoggedin(true);
         getDropboxAccountInfo();
       } catch (IllegalStateException e) {
         Toast.makeText(parentActivity, "Couldn't authenticate with Dropbox:", Toast.LENGTH_LONG)
             .show();
       }
     } // end of if authentication successful
   } else {
     // refresh Menu
     refreshMenus();
   }
 }
 @Override
 protected void onResume() {
   super.onResume();
   // Toast.makeText(ActivityTracksListView.this, "After onResume", Toast.LENGTH_SHORT).show();
   if (dropboxAuthenticationTry) {
     AndroidAuthSession session = dropbox.getSession();
     if (session.authenticationSuccessful()) {
       try {
         // Required to complete auth, sets the access token on the session
         session.finishAuthentication();
         TokenPair tokens = session.getAccessTokenPair();
         // String accessToken = dropbox.getSession().getOAuth2AccessToken();
         SharedPreferences prefs = getSharedPreferences(DROPBOX_PREF, 0);
         SharedPreferences.Editor editor = prefs.edit();
         editor.putString(APP_KEY, tokens.key);
         editor.putString(APP_SECRET, tokens.secret);
         editor.apply();
         Toast.makeText(
                 ActivityTracksListView.this, "Authentication successful", Toast.LENGTH_LONG)
             .show();
         // dropboxLoggedIn = true;
         uploadToDropbox();
       } catch (IllegalStateException e) {
         Log.i("DbAuthLog", "Error authenticating", e);
         Toast.makeText(
                 getApplicationContext(),
                 "Error during Dropbox authentication",
                 Toast.LENGTH_SHORT)
             .show();
       }
     }
     dropboxAuthenticationTry = false;
   }
 }
  @Override
  protected void onResume() {
    super.onResume();
    Toast.makeText(this, "PhotoShareActivity.onResume", Toast.LENGTH_SHORT).show();

    AndroidAuthSession session = mApi.getSession();

    // The next part must be inserted in the onResume() method of the
    // activity from which session.startAuthentication() was called, so
    // that Dropbox authentication completes properly.
    if (session.authenticationSuccessful()) {
      try {
        // Mandatory call to complete the auth
        session.finishAuthentication();

        // Store it locally in our app for later use
        TokenPair tokens = session.getAccessTokenPair();
        storeKeys(tokens.key, tokens.secret);

        uploadFiles();
        setLoggedIn(true);
      } catch (IllegalStateException e) {
        showToast("Couldn't authenticate with Dropbox:" + e.getLocalizedMessage());
        Log.i(TAG, "Error authenticating", e);
      }
    } else {
      Toast.makeText(this, "PhotoShareActivity.onResume: failed to auth", Toast.LENGTH_LONG).show();
    }
  }
Beispiel #4
0
  public boolean FinishAuthorization() {
    AndroidAuthSession session = dropboxApi.getSession();
    if (!session.isLinked() && session.authenticationSuccessful()) {
      // Mandatory call to complete the auth
      session.finishAuthentication();

      // Store it locally in our app for later use
      TokenPair tokens = session.getAccessTokenPair();
      storeKeys(tokens.key, tokens.secret);
      return true;
    }

    return false;
  }
Beispiel #5
0
 public void receiveTokenAndConnect() {
   // Dropbox API - recibe el token y se conecta
   AndroidAuthSession session = mApi.getSession();
   if (session.authenticationSuccessful()) {
     try {
       // Mandatory call to complete the auth
       session.finishAuthentication();
       // Store it locally in our app for later use
       TokenPair tokens = session.getAccessTokenPair();
       storeKeys(tokens.key, tokens.secret);
       setLoggedIn(true);
       // showToast("Logueado bien" + tokens.key + " - " + tokens.secret);
     } catch (IllegalStateException e) {
       showToast("Couldn't authenticate with Dropbox:" + e.getLocalizedMessage());
       Log.i(DropboxUtil.TAG, "Error authenticating", e);
     }
   }
 }
  @Override
  protected void onResume() {
    super.onResume();
    AndroidAuthSession session = mApi.getSession();

    // The next part must be inserted in the onResume() method of the
    // activity from which session.startAuthentication() was called, so
    // that Dropbox authentication completes properly.
    if (session.authenticationSuccessful()) {
      try {
        // Mandatory call to complete the auth
        session.finishAuthentication();

        // Store it locally in our app for later use
        storeAuth(session);
        setLoggedIn(true);
      } catch (IllegalStateException e) {
        showToast("Couldn't authenticate with Dropbox:" + e.getLocalizedMessage());
        Log.i(TAG, "Error authenticating", e);
      }
    }
  }
Beispiel #7
0
  private void checkSyncDropbox() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    // then you use
    Boolean linked = prefs.getBoolean(SetPreference.SYNC_DROPBOX, false);
    if (linked) {
      AndroidAuthSession session = SetPreference.mApi.getSession();

      // The next part must be inserted in the onResume() method of the
      // activity from which session.startAuthentication() was called, so
      // that Dropbox authentication completes properly.
      if (session.authenticationSuccessful()) {
        try {
          // Mandatory call to complete the auth
          session.finishAuthentication();

          SetPreference.uploadDB(mFileName, EditPage.this);
        } catch (IllegalStateException e) {
          showToast("Couldn't authenticate with Dropbox:" + e.getLocalizedMessage());
          Log.i(TAG, "Error authenticating", e);
        }
      }
    }
  }
Beispiel #8
0
  @Override
  protected void onResume() {
    super.onResume();

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onResume();

    try {
      /* Only activate FaceBook publish install if the user has the FaceBook app installed */
      if (com.facebook.Settings.getAttributionId(getContentResolver()) != null) {
        com.facebook.AppEventsLogger.activateApp(this);
      }
    } catch (IllegalStateException e) {
      Log.d(TAG, "Facebook Setting Exception again!");
    }

    AndroidAuthSession session = mApi.getSession();

    // The next part must be inserted in the onResume() method of the
    // activity from which session.startAuthentication() was called, so
    // that Dropbox authentication completes properly.
    if (session.authenticationSuccessful()) {
      try {
        // Mandatory call to complete the auth
        session.finishAuthentication();

        // Store it locally in our app for later use
        TokenPair tokens = session.getAccessTokenPair();
        storeKeys(tokens.key, tokens.secret);
        setLoggedIn(true);
      } catch (IllegalStateException e) {
        showToast("Couldn't authenticate with Dropbox:" + e.getLocalizedMessage());
        Log.i(TAG, "Error authenticating", e);
      }
    }
  }