예제 #1
0
  /**
   * Starts activity with url where user can grant permission to the user's Opera Link data
   *
   * @return true if redirection succeeded
   */
  private boolean redirectToBrowser() {

    try {
      String authorizeUrl = link.getAuthorizationURL(CALLBACK_URL);

      Editor prefEditor = pref.edit();
      prefEditor.putString(REQUEST_TOKEN_PREF_KEY, link.getRequestToken());
      prefEditor.putString(TOKEN_SECRET_PREF_KEY, link.getTokenSecret());
      prefEditor.commit();

      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse(authorizeUrl));
      startActivityForResult(i, REDIRECTION_ACTIVITY);
    } catch (LibOperaLinkException e) {
      e.printStackTrace();
      showToast("Could not connect to the server");
      return false;
    }
    return true;
  }