to be more specific it gives the interface that is used by other google apps to get user credentials... it also provides methods with which u can get the auth token or invalidate the token(logout)... On Fri, Jun 5, 2009 at 5:27 PM, mscwd01 <mscw...@gmail.com> wrote:
> > 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." > > > -- Regards, Sujay Will Rogers <http://www.brainyquote.com/quotes/authors/w/will_rogers.html> - "I never expected to see the day when girls would get sunburned in the places they now do." --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---