2016-06-13 139 views
0

我已經成功地集成谷歌的API來登錄使用G +帳戶,谷歌加登錄

我能夠得到用戶的電子郵件地址和姓名,我所需要的所有信息,

但我期待的方式,我如何將這些信息發送給我的開發人員電子郵件ID,以便我可以通過gmail與用戶溝通。

這裏是我使用來獲取所有的代碼,

private void getProfileInformation() { 
     try { 
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) { 
       Person currentPerson = Plus.PeopleApi 
         .getCurrentPerson(mGoogleApiClient); 
       String personName = currentPerson.getDisplayName(); 
       String personPhotoUrl = currentPerson.getImage().getUrl(); 
       String personGooglePlusProfile = currentPerson.getUrl(); 
       String email = Plus.AccountApi.getAccountName(mGoogleApiClient); 

       sharedPreferences=this.getPreferences(1); 
       edt = sharedPreferences.edit(); 
       edt.putString("personName", personName); 
       edt.putString("personPhotoUrl", personPhotoUrl); 
       edt.putString("personGooglePlusProfile", personGooglePlusProfile); 
       edt.putString("email",email); 
       edt.apply(); 
       Log.e(TAG, "Name: " + personName + ", plusProfile: " 
         + personGooglePlusProfile + ", email: " + email 
         + ", Image: " + personPhotoUrl); 


       // by default the profile url gives 50x50 px image only 
       // we can replace the value with whatever dimension we want by 
       // replacing sz=X 
       personPhotoUrl = personPhotoUrl.substring(0, 
         personPhotoUrl.length() - 2) 
         + PROFILE_PIC_SIZE; 

       new LoadProfileImage(imgProfilePic).execute(personPhotoUrl); 

      } else { 
       Toast.makeText(getApplicationContext(), 
         "Person information is null", Toast.LENGTH_LONG).show(); 
      } 
     } catch (Exception e) { 
      e.printStackTrace(); 

} }

+0

你想發送用戶的電子郵件ID到您的電子郵件地址? –

+0

是的,我想要.. –

回答

0

有兩種方法做到這一點:

  1. 要麼你傳遞一個意圖,將用戶帶到電子郵件應用程序,用戶有權發送或不發送郵件。 (這不會起作用,因爲用戶可能不想分享他們的信息)

  2. 或者您創建一個API並將用戶數據發送到您的服務器。