profile
viewpoint

Ask questionsExpose service.getProcess().getContext()

Hi @ericwlange, in relation to https://github.com/LiquidPlayer/LiquidCore/issues/138#issuecomment-558262820, it's totally up to you if it's safe to expose service.getProcess().getContext() and in what manner to expose the context. But it would really be handy if there was a standard way for this to be exposed especially that I could not get it from payload.getContext() https://github.com/LiquidPlayer/LiquidCore/issues/141.

LiquidPlayer/LiquidCore

Answer questions ericwlange

BTW, here is the workaround to get the context in Android.

public static JSContext getJSContextFromMicroService(MicroService service) {
    final JSContext[] context_ = new JSContext[1];
    final Semaphore sync_ = new Semaphore(0);
    Process.EventListener listener = new Process.EventListener() {
        @Override public void onProcessStart(Process process, JSContext ctx) {
            context_[0] = ctx;
            sync_.release();
        }
        @Override public void onProcessAboutToExit(Process process, int exitCode) {}
        @Override public void onProcessExit(Process process, int exitCode) {}
        @Override public void onProcessFailed(Process process, Exception error) {}
    });
    service.getProcess().addEventListener(listener);
    sync_.acquireUninterruptibly();
    service.getProcess().removeEventListener(listener);
    return context_[0];
}
useful!

Related questions

No questions were found.
Github User Rank List