Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7818879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:43:42+00:00 2026-06-02T06:43:42+00:00

I have searched and I have found the following codes will let my program

  • 0

I have searched and I have found the following codes will let my program read the output of the logcat in android.However,after I call this function peroidically, nothing happens.Nothing is output through system.out except the “logcat called”.I really do not know what happened because many posts here tell this will work:<

public void  Collector_logcat(){


    String stringbuffer="";
    String command="logcat -d";
    String command_c="logcat -c";
     System.out.println("logcat called\n"); 
    try{
        m_logcatprocess=Runtime.getRuntime().exec(command);
        m_logcat_inputreader=new InputStreamReader(m_logcatprocess.getInputStream());
        m_logcat_reader=new BufferedReader(m_logcat_inputreader);
      while((stringbuffer=m_logcat_reader.readLine())!=null){
          System.out.println(stringbuffer+"\n");  
      }

      Runtime.getRuntime().exec(command_c);

    }

        catch(Exception ex){
            System.out.println(ex.getMessage());
            System.out.println("error in Collector_logcat\n");
        }

     return ;

    }   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:43:43+00:00Added an answer on June 2, 2026 at 6:43 am

    try this:

    AndroidManifest.xml

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

    Get catlog:

    try {  
        ArrayList<String> commandLine = new ArrayList<String>();  
    commandLine.add("logcat");  
        commandLine.add( "-d");  
        commandLine.add( "-v");  
        commandLine.add( "time");  
        commandLine.add( "-s");  
        commandLine.add( "tag:W");  
        Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[commandLine.size()]));  
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()), 1024);  
        String line;  
        while ((line = bufferedReader.readLine()) != null) {  
            log.append(line);  
            log.append("\n")  
        }  
    } catch (IOException e) {  
    }
    

    You will get output as:

    09-08 09:44:42.267 W/tag ( 754): message1
    09-08 09:44:42.709 W/tag ( 754): message2
    09-08 09:44:43.187 W/tag ( 754): message3
    09-08 09:44:45.295 E/tag ( 754): message8

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched but have not found my answer. Disclaimer: I am brand new
I have searched for hours now and haven't found a solution for my problem.
i have searched Xcode controls but doesn't found anything that makes a GridView like
I have searched the web and have found no definitive solution, so here goes:
I have searched far and wide on the Internet but have not found anything
I have searched through internet & found that there are no any direct method
I have searched the documentation and tried various techniques but have't found a suitable
I have searched for hours for the answer to my question and have found
I have searched a bit on google, but didn't really found an answer to
I have searched around a bit, and have not really found a professional type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.