/**
   * Instantiates a new plus wrap.
   *
   * @param context the context
   */
  public PlusWrap(Context context) {
    final SharedPreferences prefs = context.getSharedPreferences(AuthUtils.PREFS_NAME, 0);
    final String accessToken = prefs.getString("accessToken", null);
    final AccessProtectedResource authInitializer =
        new AccessProtectedResource(
            accessToken, AccessProtectedResource.Method.AUTHORIZATION_HEADER);

    plus = new Plus(AndroidHttp.newCompatibleTransport(), authInitializer, new GsonFactory());
    plus.setKey(" AIzaSyCWp7NYJ-ZTVhXe9TnzYCB5wLmRg1gL6KE");
    plus.setApplicationName("PlayCez");
  }
コード例 #2
0
 /**
  * Creates an app activity in Google indicating that the given User has uploaded the given Photo.
  *
  * @param author Creator of Photo.
  * @param photo Photo itself.
  * @param credential Credential with which to authorize request to Google.
  * @throws MomentWritingException Failed to write app activity.
  */
 private void addPhotoToGooglePlusHistory(User author, Photo photo, GoogleCredential credential)
     throws MomentWritingException {
   ItemScope target = new ItemScope().setUrl(photo.getPhotoContentUrl());
   Moment content =
       new Moment().setType("http://schemas.google.com/AddActivity").setTarget(target);
   Plus plus = new Plus.Builder(TRANSPORT, JSON_FACTORY, credential).build();
   try {
     Insert request = plus.moments().insert(author.googleUserId, "vault", content);
     Moment moment = request.execute();
   } catch (IOException e) {
     throw new MomentWritingException(e.getMessage());
   }
 }
コード例 #3
0
 /** {@inheritDoc} */
 @Override
 protected void executeConnector() throws Exception {
   Plus plus = getPlusClient();
   result = plus.people().get(userId).execute();
 }