title: How to get android phone user's google account name?
body: <p>So I am making mobile game with unity engine, think to release to android target.</p>
  
  <p>Now my game will have my own custom highscore board, there I think when user earn score, game should send his identity nickname, score to server.</p>
  
  <p>So for get his distinct name, I think to get his google account name. (of course I can choose option that receive user's input for his nickname, but well, tiresome)</p>
  
  <p>I just only need email format's front part (i.e. username) 
  <strong>Example, if user's google account is asdf@gmail.com , I want to extract only "asdf".</strong></p>
  
  <p>So, how to do it?</p>
  
  <p>And is this good way for get his distinct nickname?</p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p>So I did like this, but does not work. </p>
  
  <pre><code>public class MainActivity extends UnityPlayerActivity implements        AndroidInterface{
  private String usergoogleName;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);  
      GetUserName();      
  } 
  public void GetUserName(){
      AccountManager manager = AccountManager.get(this);
      Account[] accounts = manager.getAccountsByType("com.google");
      List&lt;String&gt; username = new LinkedList&lt;String&gt;();
  
      for (Account account : accounts) {
          username.add(account.name);
      }
      usergoogleName = username.get(0);
      sendMessage("Main Camera", "JavaMsg", usergoogleName);
  }
  
  @Override
  public void sendMessage(String target, String method, String params) {
      // TODO Auto-generated method stub
      UnityPlayer.UnitySendMessage(target, method, params);
  }
  </code></pre>
  
  <p>and at unity side, I attached script to 'Main Camera' object and write, </p>
  
  <pre><code>public string name;
  public void JavaMsg(string str){
      name = str;
  }
  void OnGUI(){
      GUI.Label(new Rect(100, 200, 300, 100), "google account name is " + name);
  }
  </code></pre>
  
  <p>but when I run this at my phone after make .apk file, doesn't read account name.</p>
  
  <p>What is wrong?</p>