with regard to post #21, my inline java snippet works with b4j. it does not work as is with b4a because one of the elements referenced in the snippet does not exist in android's implementation of reflection. below please find a suitable inline snippet which does work in b4a.
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.util.List;
import java.util.ArrayList;
import java.lang.reflect.Modifier;
import java.util.Map;
import java.util.HashMap;
public static void listEnums( Object o) {
try {
// Obtain the Class object for the enum
Class<?> c = (Class) o; //Class.forName("NavigationSystem");
BA.Log("class: " + c.getCanonicalName());
// Get the enum constants
Object[] constants = c.getEnumConstants();
System.out.println("Enum Constants:");
for (Object constant : constants) {
System.out.println(" - " + constant);
}
Field[] flds = c.getDeclaredFields();
List<Field> cst = new ArrayList<Field>(); // enum constants
List<Field> mbr = new ArrayList<Field>(); // member fields
for (Field f : flds) {
if (f.isEnumConstant()) {
cst.add(f);
}
else {
mbr.add(f);
if (f.toString().contains("KEYWORDS_MAP")) {
BA.Log("found keywords map");
f.setAccessible(true);
BA.Log("setaccessible");
//NOTE: ANDROID DOES NOT HAVE A "MODIFIERS" FIELD
// THIS CODE WORKED IN B4J. APPARENTLY NOT
// NEEDED IN B4A (OR EVEN LEGAL)
/*
Field modifiers = Field.class.getDeclaredField("modifiers");
BA.Log("modifiers");
modifiers.setAccessible(true);
BA.Log("set accessible");
int mods = f.getModifiers();
BA.Log("modifiers: " + mods);
modifiers.setInt(f, f.getModifiers() & ~Modifier.FINAL);
BA.Log("unfinalized");
*/
BA.Log("field name: " + f.getName());
BA.Log("class name: " + c.getCanonicalName());
Map map = (Map) f.get(c);
BA.Log("before reflection:");
BA.Log("values: " + map.values());
BA.Log("keys: " + map.keySet());
map.put( "QZSS", map.get("QZS") );
BA.Log("upon reflection...");
BA.Log("values: " + map.values());
BA.Log("keys: " + map.keySet());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
for interested parties, orekit's library creates a map of recognized navigation systems (gps, glonoss, beidou, etc). whether by error or design, one of the systems may have been keyed incorrectly. this results in a crash when orekit's ntripclient downloads the so-called "sourcetable" data and tries to parse it. there are 4 ways to correct this (4 that i am aware of):
1) intercept the sourcetable data on download and change the unrecognized system to some that is recognized.
2) download the sourcetable separately, edit it, and repost it on your own server for download by orekit.
3) recompile the orekit library from source after editing the class that contains the errant system name.
4) use java.lan.reflect to modify the library in situ as it's running.
#1 can't be used as orekit's ntripclient downloads the data and immediately begins working on it, thus throwing the exception.
#2 i suppose this would work, although i'm not sure how it affects the realtime updating of satellite data.
#3 doesn't work with slc (file name too long error). this is presumably a job for eclipse.
#4 i went with this (not generally recommended). the part of the library that needs to be changed is declared as final and private. reflection can often get around these constraints. it can in this case. i was able to add another navigation system to orekit's code. this avoid the unrecognized system exception. what's involved is making the data object accessible and not final. since the object is a map, i added a new navigation system to it. when orekit's ntripclient downloads the data, the new system is in place, and the exception is avoided. this works as is in b4j, but android has a slightly different implementation of reflection, so i had to edited out a few lines of code which were required for b4j. to my surprise, and for whatever reason, there was no problem - ie, no exception - when the snippet was run in b4a. op seems to think the b4j version runs ok, so i'm guessing the b4a version does the same.