Can I use NativeActivity with an ActivityGroup?

I know that ActivityGroup deprecated.

But I'm trying to combine the NativeActivty with some Java / Android View s APIs.

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

I used this example and tried an ActivityGroup with some simple actions.

This works great with any Activity (Even if I play a video using VideoView).

But when I tried to load NativeActivity , it does not work. (I tried a demonstration of a teapot from NDK samples).

By "does not work" I mean window.getDecorView() from its own activity, it always returns a transparent view, and not the actual viewing of the content.

How can I do it? Please help me.

+3
source share
1 answer

This time I found a workaround for it and it works great. but only for ndk demos.

in a subclass of ActivityGroup onCreate, 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()); } 
+2
source

All Articles