11

I need to capture some information from Modem Radio Log in android. I want to do this because I need some information about baseband in android, and I found out that to do that I must capture modem log.

I found Read logcat programmatically within application for capturing logcat logs in application, but it is an adb log adb logcat -b radio, and I don't know how to capture ADB log in application.

5
  • Are you searching for adb logcat -b radio?
    – Robert
    Commented Sep 1, 2016 at 11:55
  • Yes, can I use it inside my application? Commented Sep 1, 2016 at 12:09
  • No. You have to execute it via adb or using root permissions on current Android versions.
    – Robert
    Commented Sep 1, 2016 at 12:14
  • I want to pars the Android baseband log for information about the cellular connection. How to do this in my app? Commented Sep 1, 2016 at 12:21
  • @Robert can you please help me? How to do "or using root permissions on current Android versions." Thanks Commented Sep 4, 2016 at 5:22

2 Answers 2

3

Use below command on terminal or console after adb device connection.

adb logcat -b radio

2

Try something like this:

try {
    Runtime rt = Runtime.getRuntime();
    //here you can add your params
    String[] commands = {"logcat"};
    Process proc = rt.exec(commands);

    BufferedReader stdInput = new BufferedReader(new
            InputStreamReader(proc.getInputStream()));

    BufferedReader stdError = new BufferedReader(new
            InputStreamReader(proc.getErrorStream()));

    String s;
    while ((s = stdInput.readLine()) != null) {
        //here is your logcat
        Log.i("logcat", s);
    }

    while ((s = stdError.readLine()) != null) {
        Log.e("logcat", s);
    }
 } catch (IOException e) {
    e.printStackTrace();
}

Keep in mind that you might need root to read logcat.

UPD: Working example - https://github.com/sssemil/SampleLogcatApp

4
  • Thank you @sssmeil, it is good, but when I try this command adb logcat -b radio instead of yours, it doesn't work. I think it is because that ADB commands can't get executed like this. Am I right? Commented Sep 11, 2016 at 15:21
  • You don't need to add "adb" if you are "inside". Just type "logcat -b radio". Not sure if same command is valid for internal logcat but you can still try. And you need root access in order to read other apps' logcat.
    – sssemil
    Commented Sep 11, 2016 at 15:24
  • This command is not working without adb. When I try the original command, I receive this "cannot bind 'tcp:5038'" Commented Sep 11, 2016 at 17:33
  • Try installing Android Terminal Emulator and running logcat (with and without params) command in it to check if it's working.
    – sssemil
    Commented Sep 11, 2016 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.