错误:
Application cannot be resolved to a type
SharedPreferences cannot be resolved to a type`
the method override must override or implement a super type method
Multiple markers at this line
PreferenceManager cannot be resolved
程序:
package com.su.vapour;
public class Common extends Application {
public static String[] email_arr;
private static SharedPreferences prefs;
@Override
public void onCreate() {
super.onCreate();
prefs = PreferenceManager.getDefaultSharedPreferences(this);
List<String> emailList = getEmailList();
email_arr = emailList.toArray(new String[emailList.size()]);
}
private List<String> getEmailList() {
List<String> lst = new ArrayList<String>();
Account[] accounts = AccountManager.get(this).getAccounts();
for (Account account : accounts) {
if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
lst.add(account.name);
}
}
return lst;
}
}
答案 0 :(得分:2)
您需要为此Java文件中引用的类和接口添加import
语句,例如android.app.Application
和android.content.SharedPreferences
。
import
语句是一个相当基本的Java概念。我强烈建议您学习Java,尤其是Android应用程序开发所需的key areas。