Roll-your-own native activity wrapper. Surface(View) and such.

460 views
Skip to first unread message

gadget

unread,
Mar 8, 2013, 5:01:45 PM3/8/13
to andro...@googlegroups.com
I was just re-evaluating my NativeActivity-like wrapper that funnels all the lifecycle/etc calls into the native layer. I currently use a SurfaceView which gets turned into an OpenGL context. However, while browsing the NativeActivity code here, I noticed that it does not use a SurfaceView, but instead does getWindow().takeSurface() to obtain a surface. Both methods obviously work, but I was wondering if I am taking an unnecessary performance/resources hit by creating a SurfaceView instead of taking the surface from the window?

Leigh McRae

unread,
Mar 11, 2013, 4:43:30 PM3/11/13
to andro...@googlegroups.com
I have Java Activity that creates a SurfaceView and I pass this to my
native creation code. I would advise that you do the same. This was
done to make sure my native app had a View hierarchy that plays nice
with the rest of the OS. If you want to use stuff like Ad Mob you will
need this. Really I don't see any benefit to using a Window directly
but having a View opens you up to using other features of the OS.

On 3/8/2013 5:01 PM, gadget wrote:
> I was just re-evaluating my NativeActivity-like wrapper that funnels
> all the lifecycle/etc calls into the native layer. I currently use a
> SurfaceView which gets turned into an OpenGL context. However, while
> browsing the NativeActivity code here
> <https://code.google.com/p/android-source-browsing/source/browse/core/java/android/app/NativeActivity.java?repo=platform--frameworks--base>,
> I noticed that it does not use a SurfaceView, but instead
> doesgetWindow().takeSurface() to obtain a surface. Both methods
> obviously work, but I was wondering if I am taking an unnecessary
> performance/resources hit by creating a SurfaceView instead of taking
> the surface from the window?
> --
> You received this message because you are subscribed to the Google
> Groups "android-ndk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to android-ndk...@googlegroups.com.
> To post to this group, send email to andro...@googlegroups.com.
> Visit this group at http://groups.google.com/group/android-ndk?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

gadget

unread,
Mar 11, 2013, 6:34:48 PM3/11/13
to andro...@googlegroups.com
NativeActivity accomplishes this by creating a plain View in addition to taking of the window's surface. So I suppose I should refrain the question like this:

SurfaceView ?<>=? takeSurface() + View

( ?<>=? is supposed to mean: greater/less/equal, in terms of resources)
Reply all
Reply to author
Forward
0 new messages