I am trying to itterate over public static fields in class with private constructor, but getFields/getDeclaredField returns zeroSize array, so I never so Log messages from loop. Where is an error?
Constants
public final class SyncKeysConstants {
private SyncKeysConstants() {
}
public static final String HOME = "home";
}
Method
public static void updateConnection(Context context) {
boolean connected = check(context);
Log.e("updateConnection", " current - " + connected);
for (Field f : SyncKeysConstants.class.getFields()) {
Log.e("field", " name - " + f.getName());
try {
String value = (String) f.get(null);
Log.e("field", " name - " + f.getName() + ", data - " + value);
if (connected) {
SyncStatus.setNoConnection(context, value, false);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
Aucun commentaire:
Enregistrer un commentaire