I have a piece of C code (not an NDK app, plain C code), and I am trying to send a broadcast to my app, but all I get is:
Broadcasting: Intent { act=com.example.A_NAME }
I never get the completed message.
The C code I am running is:
char broadcast[200];
sprintf(broadcast, "sh %s","com.example.A_NAME");
FILE* pipe = popen(broadcast, "r");
char buffer[128];
char result[1500];
while(!feof(pipe)) {
if(fgets(buffer, 128, pipe) != NULL)
sprintf(result, "%s%s", result,buffer);
}
pclose(pipe);
For a simple bash script, I can get this working. From C, I tried system()
, execl()
etc, but nothing.
I also tried to put the command in a script file, and execute the script file. If I execute the script from adb shell, it works. If I do it from C code, it does not work.