开发者

100% Native C Application on Android?

开发者 https://www.devze.com 2023-02-19 14:00 出处:网络
Is there anyway I could write 10开发者_运维知识库0% native C code for Android?I know there are ways to write some C code inside Java code, but I don\'t know any Java and I hate Java anyway.

Is there anyway I could write 10开发者_运维知识库0% native C code for Android? I know there are ways to write some C code inside Java code, but I don't know any Java and I hate Java anyway.

Is there anyway I could write pure C code that will run under Android?


There is, as of Android 2.3: NativeActivity. But you don't get access to any of the niceties of Android's Java libraries; you're on your own in the wild west. This is really intended for people writing high-performance games.


Yes, there is support for writing completely native activities. You can check out the native-activity sample application.

I would not recommend this path, though, as in my experience applications that are heavy in NDK code are very difficult to debug. I would rate the Android native debugging experience as lacking.

Edit - one caveat is that you will still be doing plently of Java--just through the JNI.


Might be more trouble than it's worth, you could possibly write your logic in C code and import that to java using extern or external (I forget which now) and then do the GUI in java. There's really no point to using straight C in android unless you want to REALLY optimized your logic. Most of the calls you can make are wrapped anyways so you would have to make those calls to access certain things on an android device. Long story short : not a good idea unless you need faster logic.


You can write most of the application in C around a NativeActivity. However, some Android features can only be used from Java, so you'll need to use JNI instead of pure native. See the official overview.

0

精彩评论

暂无评论...
验证码 换一张
取 消