Native Activity vs SDK Activity in terms of U.I

核能气质少年 提交于 2019-12-24 12:15:47

问题


I've been doing a fair amount of research, and have even experimented some with the NDK for Android (not so much the SDK). What I haven't been able to really find though is a clear and concise definition for what the NDK cannot do (besides lack of exception handling and rtti).

I've been mapping out some code for a game and a game engine for Android (Written entirely in the NDK) but it seems to not be as supported as many would like it to be. Not only that, but I'd like to be able to give my game a sexy U.I. without having to write everything from scratch in OpenGL.

While I'm sure it's easier in Java, I'd like to know if the NDK's front end/U.I. components are getting to a point to where they'd even be comparable with Java in terms of Touchscreen IO , Sound, and Graphical Interfaces. Worst case scenario I can write the U.I. in Java and just call native methods from that, but I'd like to be able to do more if possible.

Thanks.

Edit

If C++ is even somewhat on par with Java's U.I. feature set, it would be cool to know which of the two gives more control and customization. For example, while the Java implementation may be easier to use, does it give the programmer a lot of options to fine tune a "look" which resembles something specific?


回答1:


Official NDK can do exceptions and rtti just fine. Read the "docs/CPLUSPLUS-SUPPORT.html" file distributed with Android NDK.

In C++ only thing you can not do is implement Java interface, inherit Java class and define new Java class. Otherwise - you can do everthing Java can. Only problem with that will be that a lot of things (like accessing Java object members, or calling Java functions) will require usage of JNI and that code will look really ugly. So if you need for UI creating/inheritance of Java classes, then you can code everything in C++.

I suggest to use JNI only for performance critical code. Mixing code - Java for UI, mathematical calculations in C/C++ is really easy. Or if you code game by using OpenGL ES - that's also fine.



来源:https://stackoverflow.com/questions/10308746/native-activity-vs-sdk-activity-in-terms-of-u-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!