本測試使用Android Studio 進行開發,請注意確定已加入google Play Service 的 Module 進入專案中。

於build.gradle 內新增以下設定 :

dependencies {
    compile 'com.google.android.gms:play-services-auth:8.4.0'
}

 

於 AndroidManifest.xml 加入以下權限 :

<uses-permission android:name="android.permission.GET_ACCOUNTS" />

 

Java Code :

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;


AccountManager accountManager = AccountManager.get(context);
Account[] accounts = accountManager.getAccounts();
for(Account account : accounts){
	Log.i("--Get Account Example--", account.name);
	Log.i("--Get Account Example--", account.type);
}

 

 

arrow
arrow
    文章標籤
    Android Account
    全站熱搜

    Lung-Yu,Tsai 發表在 痞客邦 留言(0) 人氣()