1

I'm trying to get the log of my app. Android 4.1.2 (Huawei tablet)

This is the code that I'm using

StringBuilder log=new StringBuilder();
        try {  
            Process process = Runtime.getRuntime().exec("logcat -d");  
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));  


            String line;  
            while ((line = bufferedReader.readLine()) != null) {                

              log.append(line); 
              log.append(System.getProperty("line.separator"));
            }  
            System.out.println(line == null);

          } catch (IOException e) { 
             System.out.println("error");
              e.printStackTrace();
          }  

I have added ther permissions to manifest

<uses-permission android:name="android.permission.READ_LOGS" />

When I try to read it bufferedReader is null and nothing is added to log variable.

EDIT:

I've founded this info

INFO

Apparently Huawei devices have service loggin disabled by default. I've tried the solution of the post but it doesn't work for me because "service loggin" option doesn't appears

Can someone help me?

Thanks

Community
  • 1
  • 1
Hanzo
  • 1,839
  • 4
  • 30
  • 51

1 Answers1

-2
untime.getRuntime().exec(new String[]{"logcat", "-d"})
Caleb Kleveter
  • 11,170
  • 8
  • 62
  • 92
Shahar
  • 1
  • 1