Ok, it turns out I cannot call getActivity() directly from FREContext. I had to set it via my FREFunction:
public class MyFunction implements FREFunction {
@Override
public FREObject call(FREContext context, FREObject[] passedArgs) {
MyExtensionContext mec = (MyExtensionContext) context;
// Set a local variable in MyExtensionContext to getActivity value
mec.act = mec.getActivity();
mec.doThreadWork();
return null;
}
}
And my FREContext now looks like this:
public class MyExtensionContext extends FREContext {
public Activity act;
public void doThreadWork() {
new Thread(new Runnable() {
@Override
public void run() {
// Do stuff with Activity "act" here
}
}
}
}
I'm not entirely sure why this works since it seems like an extra step that's getting the same getActivity() value, but it could be that this Activity is created at a different time than in FREContext.