i was working in android ndk and found that the following function
int err = service->dump(STDOUT_FILENO, args);
print the dump of service on console but it to print it in file,how can i do that
i have written the following function to take data in buffer
#define LOGFILE "C:\\MyServices\\dump.txt"
#define buffer 2500
int WriteToLog(char* str)
{
FILE* log;
log = fopen(LOGFILE, "a+");
if (log == NULL)
return -1;
fprintf(log, "%s\n", str);
fclose(log);
return 0;
}
if want to print something in file i used to do like this:-
for (size_t i=0; i<N; i++) {
sp<IBinder> service = sm->checkService(services[i]);
if (service != NULL) {
sprinf(buffer,"services[%d] = %s",i,services[i]);
WriteToLog(buffer);
aout << " " << services[i] << endl;
but don't know how to take data from this function
int err = service->dump(STDOUT_FILENO, args);
into the file.
Can anybody tell this?