Android Open Source - nwcloud-androidgcm-app Android Utils






From Project

Back to project page nwcloud-androidgcm-app.

License

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.

Java Source Code

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;
      }
  }
}




Java Source Code List

org.sapmentors.nwcloud.gcm.GCMIntentService.java
org.sapmentors.nwcloud.gcm.MainActivity.java
org.sapmentors.nwcloud.gcm.backend.MobileDevice.java
org.sapmentors.nwcloud.gcm.backend.NWCloudBackend.java
org.sapmentors.nwcloud.gcm.backend.PushMessageExternal.java
org.sapmentors.nwcloud.gcm.model.PushMessageResponse.java
org.sapmentors.nwcloud.gcm.util.AndroidUtils.java