Android: Showing last MCServer related logcat message
git-svn-id: http://mc-server.googlecode.com/svn/trunk@753 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
b6138129e6
commit
cc13cbbe3d
@ -4,12 +4,12 @@
|
|||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0" >
|
android:versionName="1.0" >
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="10" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.READ_LOGS"/>
|
<uses-permission android:name="android.permission.READ_LOGS"/>
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="10" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name" >
|
||||||
|
@ -14,12 +14,12 @@ public final class R {
|
|||||||
public static final int ic_launcher=0x7f020000;
|
public static final int ic_launcher=0x7f020000;
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int ip_address=0x7f050005;
|
public static final int ip_address=0x7f050004;
|
||||||
public static final int server_status_text=0x7f050004;
|
public static final int server_status_text=0x7f050003;
|
||||||
public static final int start_server=0x7f050002;
|
public static final int start_server=0x7f050001;
|
||||||
public static final int stop_server=0x7f050003;
|
public static final int stop_server=0x7f050002;
|
||||||
public static final int textView1=0x7f050000;
|
public static final int textView1=0x7f050005;
|
||||||
public static final int textView2=0x7f050001;
|
public static final int textView2=0x7f050000;
|
||||||
}
|
}
|
||||||
public static final class layout {
|
public static final class layout {
|
||||||
public static final int main=0x7f030000;
|
public static final int main=0x7f030000;
|
||||||
|
@ -5,12 +5,6 @@
|
|||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView1"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/hello" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView2"
|
android:id="@+id/textView2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -44,4 +38,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/your_ip" />
|
android:text="@string/your_ip" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView1"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.73"
|
||||||
|
android:text="@string/hello" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -130,7 +130,8 @@ void cLog::Log(const char * a_Format, va_list argList)
|
|||||||
|
|
||||||
// Print to console:
|
// Print to console:
|
||||||
#if defined(ANDROID_NDK)
|
#if defined(ANDROID_NDK)
|
||||||
__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
|
//__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
|
||||||
|
__android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() );
|
||||||
//CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line );
|
//CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line );
|
||||||
#else
|
#else
|
||||||
printf("%s", Line.c_str());
|
printf("%s", Line.c_str());
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
package com.mcserver;
|
package com.mcserver;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@ -17,6 +22,7 @@ import android.widget.TextView;
|
|||||||
public class MCServerActivity extends Activity {
|
public class MCServerActivity extends Activity {
|
||||||
MainThread mThread = null;
|
MainThread mThread = null;
|
||||||
Thread ServerStatusThread = null;
|
Thread ServerStatusThread = null;
|
||||||
|
boolean mbExiting = false;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
@ -24,6 +30,9 @@ public class MCServerActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
|
Log.e("MCServer", "p id: " + android.os.Process.myPid() );
|
||||||
|
|
||||||
|
|
||||||
((Button)findViewById(R.id.start_server)).setOnClickListener( new View.OnClickListener() {
|
((Button)findViewById(R.id.start_server)).setOnClickListener( new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if( mThread == null || mThread.isAlive() == false ) {
|
if( mThread == null || mThread.isAlive() == false ) {
|
||||||
@ -62,6 +71,51 @@ public class MCServerActivity extends Activity {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Thread loggerThread = new Thread( new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
Process process = null;
|
||||||
|
|
||||||
|
SetText( "herpaderpa" );
|
||||||
|
|
||||||
|
try {
|
||||||
|
process = Runtime.getRuntime().exec("logcat -v raw *:s MCServer ");// Verbose filter
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedReader reader = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while( mbExiting == false ) {
|
||||||
|
line = reader.readLine();
|
||||||
|
if( line != null )
|
||||||
|
{
|
||||||
|
SetText( line );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i("MCServer", "Prepping thread for termination");
|
||||||
|
reader.close();
|
||||||
|
process.destroy();
|
||||||
|
process = null;
|
||||||
|
reader = null;
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loggerThread.start();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
((TextView)findViewById(R.id.ip_address)).setText("Connect to: " + getLocalIpAddress());
|
((TextView)findViewById(R.id.ip_address)).setText("Connect to: " + getLocalIpAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +172,14 @@ public class MCServerActivity extends Activity {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void onDestroy() {
|
||||||
|
mbExiting = true;
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void AddToLog( String logMessage ) {
|
public void AddToLog( String logMessage ) {
|
||||||
|
|
||||||
@ -128,7 +190,7 @@ public class MCServerActivity extends Activity {
|
|||||||
|
|
||||||
|
|
||||||
public void SetText( final String aText ) {
|
public void SetText( final String aText ) {
|
||||||
Log.d("MCServer", "in SetText " + aText);
|
//Log.d("MCServer", "in SetText " + aText);
|
||||||
/*
|
/*
|
||||||
final MCServerActivity context = this;
|
final MCServerActivity context = this;
|
||||||
this.runOnUiThread(new Runnable()
|
this.runOnUiThread(new Runnable()
|
||||||
@ -180,18 +242,6 @@ class MainThread extends Thread {
|
|||||||
mContext = aContext;
|
mContext = aContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddToLog( String logMessage ) {
|
|
||||||
mContext.SetText( logMessage );
|
|
||||||
//Log.d("MCServer", "Add to log: " + logMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TestTest(){
|
|
||||||
numlogs++;
|
|
||||||
//Log.d("MCServer", "in testtest" + numlogs);
|
|
||||||
mContext.Testtt();
|
|
||||||
mContext.SetText("log no. " + numlogs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
mContext.NativeOnCreate();
|
mContext.NativeOnCreate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user