【问题标题】:Should I never use native (C/C++) libraries for interacting with devices?我不应该使用本机 (C/C++) 库与设备交互吗?
【发布时间】:2011-06-27 20:21:53
【问题描述】:

请阅读this 问题,了解我想要达到的目标的一些背景知识。在互联网上寻找答案时,我发现了this 线程。在这个帖子中,一位 Google 的员工谈到了使用本机 (C/C++) 库来访问相机

You CANNOT do that. Please, understand that Native APIS ARE NOT PUBLIC
(sorry for shouting).
All these APIS may/will go away or change in ways that will make your
application *crash* in the near future.
We are not, and will not, try to maintain binary compatibility on native APIs.

You *can* use native code if you wish, but you ABSOLUTELY CANNOT call
into Android native APIs. That's a no-no. And you won't find help from
the Android team here about this subject.

我的问题:这是否意味着在任何情况下都不应尝试使用本机库处理任何设备,如加速度计、相机、指南针等?

【问题讨论】:

    标签: android


    【解决方案1】:

    是的。正如他所写,这些 API 是内部的,并且可能会在版本和模型之间发生变化。每个供应商都可能在此处更改任何内容,很快您的应用程序将停止在许多设备上运行。

    【讨论】:

    • 我的理解是,这些原生库位于 android 架构的“库”部分,不需要与特定供应商做任何事情。我认为这些是应用程序框架使用的通用库。不是这样吗?
    • 应用程序框架使用这些,因此您不会使用它们,并为您提供一个接口,即使特定供应商不会更改这些(我认为他们会很多次),它可能会被更改在下一个版本的android中。
    猜你喜欢
    • 2012-02-07
    • 1970-01-01
    • 2011-08-13
    • 2012-02-07
    • 1970-01-01
    • 2021-08-26
    • 1970-01-01
    • 2012-06-23
    • 2015-05-25
    相关资源
    最近更新 更多