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.

cigien
  • 57,834
  • 11
  • 73
  • 112
Mustafa Mohammadi
  • 1,433
  • 1
  • 12
  • 25

2 Answers2

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

sssemil
  • 279
  • 6
  • 15
  • 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? – Mustafa Mohammadi Sep 11 '16 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 Sep 11 '16 at 15:24
  • This command is not working without adb. When I try the original command, I receive this "cannot bind 'tcp:5038'" – Mustafa Mohammadi Sep 11 '16 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 Sep 11 '16 at 18:58