Can I use NativeActivity with ActivityGroup?
Asked Answered
H

1

4

I know ActivityGroup is deprecated.

But I am trying to combine user interface of NativeActivty with some Java/Android API Views.

I am trying to make one hybrid user interface where a part of the screen is from NativeActivity.

I used this example and tried ActivityGroup with some simple activities.

This work perfectly with any Activity (Even if I play video using VideoView).

But when I tried to load NativeActivity it not working. (I tried Teapot demo from NDK samples).

By "not working" I mean window.getDecorView() from native activity it always return transparent view, not actual content view.

How should I do it? Please help me.

Hardman answered 6/10, 2014 at 13:34 Comment(0)
O
2

This time I found a workaround for it, and works fine. but just for the ndk demos.

on your ActivityGroup sub class onCreate method, write the following code.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LocalActivityManager lam = getLocalActivityManager();

    Intent intent = new Intent();
    intent.setClass(this, TeapotNativeActivity.class);

    Window window = lam.startActivity("xxx", intent);

    // reflect call "willYouTakeTheSurface"
    NativeActivity callback = JavaCalls.callMethod(window.getDecorView(), "willYouTakeTheSurface");
    if (callback != null) {
        window.takeSurface(null);
        getWindow().takeSurface(callback);
        getWindow().takeInputQueue(callback);
    }


    setContentView(window.getDecorView());

}
Oshiro answered 18/12, 2014 at 7:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.