Runtime exec not behaving like adb exec

Search This thread

Muha12

Member
Oct 5, 2009
13
0
I've built a C++ native Android app with NDK toolcahain.

I've first tested the app using the adb tool and got the following output:

Code:
generic:/ $ run-as cardservice.hr.cardservice                                               
generic:/data/data/cardservice.hr.cardservice $ cd card/                                    
generic:/data/data/cardservice.hr.cardservice/card/ $ ./cardService 
2016-11-30 20:36:06,245 INFO  [default] Starting CardService
App continues to run
But problem starts when I try to do the same thing from a Android application.

The following code:

Code:
private void exec_command() throws IOException, InterruptedException {
    String command = "./data/data/cardservice.hr.cardservice/card/cardService"
    Process check_card_service = Runtime.getRuntime().exec(command);
    BufferedReader in = new BufferedReader(new InputStreamReader(check_card_service.getInputStream()));
    String line;
    String content = "";
    while ((line = in.readLine()) != null) {
        System.out.println(line);
        content = content + line;
    }
    check_card_service.waitFor();
};

It starts the application but the application fails, and stops working.

Code:
2016-11-30 19:25:11,417 INFO  [default] Starting CardService
2016-11-30 19:25:11,447 INFO  [default] Underlying Transport Error, Code: websocketpp.transport.asio:3

So my question is what is different in my approaches, what changes if i run it from my app or from the adb shell?

The application does not need root access.

Do you need any extra information?