0

I have an application running on Win that the JavaScript would capture the string from a webpage and wake up the cmd, cmd would have the parameter as below.

bridgetool.exe -c serial -p com1: -b 384000 -s string_from_webpage

bridgetool.exe is software that transfers the string into the RS232 String and sends the string via comport which defined in the CMD line.

-s is the string parameter from the webpage.

I want to do the same thing on Android. But instead of sending it via Serial, it would send the information via Bluetooth. And use a Bluetooth to the serial module to transfer this order.

I am not an Android programmer so before I start to work, I want to make sure that Android can do:

  • Is it possible to call terminal and pass the parameter in Android?

I understood that I can use some app to run a terminal command and send information via Bluetooth. But is it possible that an APP/Script can call the Terminal APP and pass the parameter? Like what I did on Windows. So the Terminal can transfer the parameter into an RS232 String and send it via Bluetooth?

migrated from superuser.com Jan 7 at 21:17

This question came from our site for computer enthusiasts and power users.

0

No. Android does not really have a commandline environment intended for use by Apps. There is to a limited extent one available for development, and launching subprocesses from an App is highly discouraged but technically possible, however applications run under highly restricted user accounts which cannot do much on their own, and most systems services are only provided by Java APIs that make requests through interprocess communication.

So you'll basically have to do this in the Java-level code of an application.

A little web searching will find you examples for how to interact with bluetooth devices from Android application code. Do note that there are many varieties of bluetooth target, so that aspect of your question would be too broad, but additionally stack exchange sites are not a code writing or code finding service - you will have to do your own research there.

Android does often utilize a principle of delegating tasks to something else, but the utilized mechanism is not invoking a subprocess as a terminal command would, but rather sending an "Intent" - an Android-unique mechanism for making a request for a particular action, which Application components can either make, or register their ability to handle if made by other components. There are no standard Intents for doing what you want to do, but it would be possible to create a component which sends bluetooth messages upon receiving an Intent request to do so, and then utilize that either within the same Application or in a different one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy