Back to project page nwcloud-androidgcm-app.
The source code is released under:
Apache License
If you think the Android project nwcloud-androidgcm-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.sapmentors.nwcloud.gcm.util; /*from w w w. j ava 2 s. com*/ import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; import android.util.Log; public class AndroidUtils { private static final String LOG_PREFIX = "NWCloud-app"; public static String getPrimaryAccountEmail(Context context){ AccountManager accountManager = AccountManager.get(context); Account[] accounts = accountManager.getAccountsByType("com.google"); if(accounts==null || accounts.length==0){ Log.w(LOG_PREFIX, "Could not find name of primary google account. Returning null" ); return null; }else { String name = accounts[0].name; Log.d(LOG_PREFIX, "Found "+accounts.length + " google accounts. Returning name:"+ name ); return name; } } }