Does this code allow you to get the email address of the phones owner,
used when setting up the phone? I.e. the email address of the google
account tied to to the phone?

On Jun 5, 7:54 am, Sujay Krishna Suresh <sujay.coold...@gmail.com>
wrote:
> hi guys i finally got a simple method to get the google accounts in SDK
> 1.5...
> i'm attaching the code for everyone who needs this piece of code...
> This piece of code prints all methods in the class & invokes the static
> method getAccount...
> try {
>   for (Method ele :
> Class.forName("com.google.android.googlelogin.GoogleLoginServiceHelper").getMethods())
> {
>   System.out.println(ele.toString());
>   try {
>   if(ele.getName().equals("getAccount"))
>   ele.invoke(null, this, 123, true);
>   } catch (IllegalArgumentException e) {
>   e.printStackTrace();
>   } catch (IllegalAccessException e) {
>   e.printStackTrace();
>   } catch (InvocationTargetException e) {
>   e.printStackTrace();
>   }
>   }
>   } catch (ClassNotFoundException e) {
>   e.printStackTrace();
>   }
>
>   } catch (ClassNotFoundException e) {
>   e.printStackTrace();
>   }
>
> & jus place the foll code in ur onactivityresult
> if (requestCode == 123) {
>   System.out.println(resultCode);
>   String key = "accounts";
>   System.out.println(key + ":" +
> Arrays.toString(data.getExtras().getStringArray(key)));
>   String accounts[] = data.getExtras().getStringArray(key);
>   if (accounts[0] != null)
>   usernameText.setText("You are : " + accounts[0].replace("@gmail.com",
> ""));
>  }
> in the logcat/ddms o/p u'll be able to see that there are other useful
> methods...
> public static void
> com.google.android.googlelogin.GoogleLoginServiceHelper.getCredentials(android.app.Activity,int,android.os.Bundle,java.lang.String,java.lang.String,boolean)
> public static void
> com.google.android.googlelogin.GoogleLoginServiceHelper.getCredentials(android.app.Activity,int,android.os.Bundle,boolean,java.lang.String,boolean)
> public static void
> com.google.android.googlelogin.GoogleLoginServiceHelper.invalidateAuthToken(android.app.Activity,int,java.lang.String)
>
> --
> Regards,
> Sujay
> Mark Twain <http://www.brainyquote.com/quotes/authors/m/mark_twain.html>  -
> "There is no sadder sight than a young pessimist."
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to