阅读背景:

使用PowerMockito将Context作为参数进行模拟静态方法

来源:互联网 

I have class with static method

我有静态方法的课

public class GrandUtils {

    /**
     * Return list of existing user's emails
     *
     * @param c context of the app
     * @return list of existing accounts in system or empty list
     */
    public static Set<String> getAccountsList(Context c) {
        Set<String> accountsList = new HashSet<>();
        Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
        Account[] accounts = AccountManager.get(c).getAccounts();
        for (Account account : accounts) {
            if (emailPattern.matcher(account.name).matches()) {
                accountsList.add(account.name);
            }
        }
        return accountsList;
    }
}
pu



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: