Remove All Ads from XDA

Runtime exec not behaving like adb exec

13 posts
Thanks Meter: 0
By Muha12, Junior Member on 1st December 2016, 07:25 PM
Post Reply Email Thread
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:

generic:/ $ run-as                                               
generic:/data/data/ $ cd card/                                    
generic:/data/data/ $ ./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:

private void exec_command() throws IOException, InterruptedException {
    String command = "./data/data/"
    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) {
        content = content + line;
It starts the application but the application fails, and stops working.

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?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes