get Logcat Logs - Android App

Android examples for App:Log

Description

get Logcat Logs

Demo Code

/*******************************************************************************
 * Copyright (c) 2011 MadRobot.//from   w w w  .j av a2 s .c  o  m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *  Elton Kent - initial API and implementation
 ******************************************************************************/
//package com.java2s;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    /**
     * 
     * @return
     * @throws IOException
     */
    public static InputStream getLogcatLogs() throws IOException {
        ProcessBuilder builder = new ProcessBuilder("logcat", "-d");
        builder.redirectErrorStream(true);
        Process process = builder.start();
        //process.waitFor();
        return process.getInputStream();
    }
}

Related Tutorials