Android 键入编辑文本时获取电子邮件建议?
我正在我的应用程序的注册屏幕上工作。我需要在打字时收到电子邮件建议。它不需要与Gmail Id帐户同步。它应该获得我正在使用的电子邮件id作为帐户,我们可以在帐户设置中看到它。用户应该在他的android手机中拥有Gmail帐户Android 键入编辑文本时获取电子邮件建议?,android,settings,Android,Settings,我正在我的应用程序的注册屏幕上工作。我需要在打字时收到电子邮件建议。它不需要与Gmail Id帐户同步。它应该获得我正在使用的电子邮件id作为帐户,我们可以在帐户设置中看到它。用户应该在他的android手机中拥有Gmail帐户 import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; /** * This class uses the Ac
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
/**
* This class uses the AccountManager to get the primary email address of the
* current user.
*/
public class UserEmailFetcher {
static String getEmail(Context context) {
AccountManager accountManager = AccountManager.get(context);
Account account = getAccount(accountManager);
if (account == null) {
return null;
} else {
return account.name;
}
}
private static Account getAccount(AccountManager accountManager) {
Account[] accounts = accountManager.getAccountsByType("com.google");
Account account;
if (accounts.length > 0) {
account = accounts[0];
} else {
account = null;
}
return account;
}
}
明显地
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
资料来源: