Android应用程序如何调用外部程序?
我找到了它:http://gitorious.org/android-obex/pages/Home
我想从我的 Android 应用程序中调用它,有人知道该怎么做吗?
I've found it: http://gitorious.org/android-obex/pages/Home
I would like to call it from my Android app, does anyone know how to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您链接的页面上的命令行工具似乎旨在从开发人员手机上可用的根 adb shell 使用,并且可能不使用给定消费者手机上实际可用的蓝牙堆栈版本。使用独立可执行文件也不是“android 方式”。通常,您应该将代码构建到一个库中,以便在应用程序的进程中通过 jni 调用,但如果您需要在可能的设备上以 root 身份运行代码,则必须将其作为单独的进程运行(因为您的应用程序本身无法以 root 身份运行)。
如果您想在 root 设备上使用此代码,请查找有关如何执行 su 命令并将命令行程序的名称和参数通过管道传输到其中的众多 Stack Overflow 答案之一。这将很难工作,不受支持,并且肯定不适用于所有设备。
如果您想以“android 方式”做事,请考虑编写或调整代码,以便将其插入当前的 android 蓝牙 api。这很可能是 java 代码,尽管您可以检查是否有适当的本机 API 或通过 jni 使用本机代码中的 java 代码。
The command line tools on the page you linked appear to be intended for use from the root adb shell available on developer phones, and may not be using a version of the bluetooth stack actually available on a given consumer phone. The use of stand alone executables is also not the "android way". Normally, you should build the code into a library to invoke via jni within your application's process, though if you need to run the code as root on a device where that is possible, then it will have to be run as a separate process (since you app itself cannot run as root).
If you want to play with this code on a rooted device, look for one of the many Stack Overflow answers on how to exec the su command and pipe the name and parameters of a command line program into it. This will be tricky to get working, unsupported, and will definitely not work on all devices.
If you want to do things the "android way" look into writing or adapting code so that it plugs into the current android bluetooth apis. That's likely to be java code, though you can check if there are appropriate native APIs or use the java ones from native code through jni.
阅读此内容会对您有所帮助:
使用意图,您可以启动活动或服务,并且
因此,您需要做的就是确定哪些 Intent 可以接收您想要启动的应用程序,并发送特定的广播 Intent。如果应用程序已安装,它将启动,否则什么也不会发生。
希望有帮助。
It will be useful for you to read this:
Using Intents you can start activity or service, and
So everything you need is to determine what Intents can reсeive application you want to start, and to send specific broadcast intent. If application is installed, it will be launched, otherwise nothing will happen.
Hope it helps.