I am new to android programming and development. I am working on app that auto generates a log file and attaches it to an email. The problem I am having is making the log stop running. It generates the .text file to the sd card to attach to the email, but the log keeps running and never stops. The only way I am able to attach the log is to power cycle the phone and stop the log from running. I have looked at the timer class, but I am not sure if that is what I need or if there is another way to do this. Here is the beginning and end, I left out the intents in the middle due to just being email intents.
private void submit() {
try {
log.createNewFile();
String cmd = "logcat -f "+log.getAbsolutePath();
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
}
startActivity(Intent.createChooser(emailIntent, "Send report..."));
String log = "file:///sdcard/log.txt";
try {
Runtime.getRuntime().exec("rm "+log);
} catch (IOException e) {
e.printStackTrace();
}
How about this?
When you are ready to kill the process :