- tải xuống framework.jar từ: http://github.com/android/platform_frameworks_opt_com.google.android/ ... và thêm nó vào đường dẫn xây dựng của bạn. đây là một số loại giao diện cho các chức năng của thiết bị Google .
gọi phương pháp:
com.google.android.googlelogin.GoogleLoginServiceHelper.getAccount (hoạt động Hoạt động, int requestCode, boolean requireGoogle);
nơi: Hoạt động: là hoạt động của bạn mà có được kết quả trong onActivityResult() requestCode: mã của bạn requireGoogle: phải đúng
EX. GoogleLoginServiceHelper.getAccount (mActivity, 123, true);
3.override các onActivityResult() như:
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
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 != null){
int i = 0;
for(String ac : accounts){ //each account is the full
email address registered with this device
System.out.println("ac " + i + "=" + ac);
i++;
}
}
}
bài gốc là here
cũng thêm sự cho phép để biểu thị file:
sử dụng-permission> – sohilvTôi không thấy GoogleLoginServiceHelper trong bình này. Tuy nhiên, có một GoogleLoginServiceBlockingHelper nhưng không có phương thức getAccount – BoD
Bạn phải tải xuống bản sửa đổi trước đó, tìm kiếm phiên bản có chứa GoogleLoginServiceHelper, tôi đã tìm thấy nó và nó hoạt động: D – Thys