Android的NDK的限制?Android、NDK

2023-09-05 02:17:00 作者:泪落在梦中

我有一个关于你可以在本地code执行Android平台上有什么限制问题。

I have a question about the limitations of what you can do in native code on the Android platform.

基本上,我已经开发了一个使用UDP套接字的SIP / RTP和使用的OpenAL音频录制/播放本机C code库 - 基本上整个应用程序。 我们的想法是让尽可能多的在本地C code,而不是Java的code。我想这样做,因为我打算用它在其他平台上也是如此。

Basically I have developed a library in native C code that uses UDP sockets for SIP/RTP and uses OpenAL for audio recording/playback - basically the whole application. The idea is to have as much as possible in native C code rather than Java code. I want to do this because I am going to use it on other platforms as well.

我的问题,然后是简单的 - 这可能只是使用Java的图形用户界面,然后在本地code所有处理? 当我的祖国code尝试创建一个套接字,将其绑定会发生什么,录音,播放等 - 因为它是原生code,我需要为它设置权限(如应用程序访问麦克风和诸如此类的东西),或者将它只是绕过这个东西,因为其天然code? 可以原生code做pretty的任何东西,它希望在Android上像在电脑上?

My question then is simply - is it possible to just use the Java for the GUI and then all processing in native code? What will happen when my native code tries to create a socket, bind it, record audio, play it, etc - since it is in native code, do I need to setup permissions for it (such as application accessing microphone and whatnot) or will it just bypass this stuff since its native code? Can native code do pretty much anything it wants on Android like on PCs?

很抱歉,如果不明确的;只是告诉我会尽力改进它

Sorry if its unclear; just tell and I'll try to improve it

感谢

推荐答案

您可以做你想做的本土code pretty的任何东西,但唯一的操作系统级别的东西真正的支持是OpenGL的,OpenSL和一些数字运算库(COM pression,数学等)。

You can do pretty much anything you want in native code, but the only OS-level thing really supported is OpenGL, OpenSL, and some number-crunching libraries (compression, math, etc).

然而,在任何时候你可以自由地使用JNI调用Java方法,所以你可以使用标准的Andr​​oid API进行联网(类,如插槽,等等)。很明显,因为调用会通过Java API,所有正常的Andr​​oid应用权限(如 android.permission.INTERNET对)。

However, at any time you're free to use the JNI to call a Java method, so you could use the standard Android API for networking (classes like Socket, etc). Obviously, since the call is going through the Java API, all the normal Android permissions apply (like android.permission.INTERNET).

编辑:正如在评论,说是NDK的一部分,标准库做有插座支持

As elaborated in the comments, the standard libraries that are part of the NDK do have support for sockets.