1
0
mirror of https://github.com/moparisthebest/SSLDroid synced 2024-11-27 03:12:18 -05:00

Added refresh menu option to the logview activity

Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
Balint Kovacs 2011-05-04 12:32:34 +02:00
parent 56e9474829
commit 4974177603

View File

@ -7,55 +7,59 @@ import java.io.InputStreamReader;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
public class SSLDroidReadLogs extends Activity{
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem refresh = menu.add("Refresh");
refresh.setIcon(android.R.drawable.ic_menu_rotate);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
refreshLogs();
return true;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.read_logs);
refreshLogs();
}
public void refreshLogs(){
TextView logcontainer = (TextView) findViewById(R.id.logTextView);
logcontainer.setText("");
Process mLogcatProc = null;
BufferedReader reader = null;
try
{
try {
mLogcatProc = Runtime.getRuntime().exec(new String[]
{"logcat", "-d", "-v", "time", "-b", "main", "SSLDroid:D SSLDroidGui:D *:S" });
reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream()));
String line;
//final StringBuilder log = new StringBuilder();
String separator = System.getProperty("line.separator");
while ((line = reader.readLine()) != null)
{
logcontainer.append(line);
logcontainer.append(separator);
while ((line = reader.readLine()) != null){
logcontainer.append(line+separator);
}
//logcontainer.setText(log);
}
catch (IOException e)
{
} catch (IOException e) {
Log.d("SSLDroid", "Logcat problem: "+e.toString());
}
finally
{
finally {
if (reader != null)
try
{
try {
reader.close();
}
catch (IOException e)
{
} catch (IOException e) {
Log.d("SSLDroid", "Logcat problem: "+e.toString());
}
}
}