summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-19 01:42:27 +0200
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-19 01:42:27 +0200
commitcc13cbbe3d3a95735ca037f7382ffbcc90e7a80d (patch)
treead2a02af47948c0f92d381a9c9d33c7d925d5f61 /src
parentAndroid: I'm probably using a lot of bad practices, but the app looks somewhat better now and polls the server status (diff)
downloadcuberite-cc13cbbe3d3a95735ca037f7382ffbcc90e7a80d.tar
cuberite-cc13cbbe3d3a95735ca037f7382ffbcc90e7a80d.tar.gz
cuberite-cc13cbbe3d3a95735ca037f7382ffbcc90e7a80d.tar.bz2
cuberite-cc13cbbe3d3a95735ca037f7382ffbcc90e7a80d.tar.lz
cuberite-cc13cbbe3d3a95735ca037f7382ffbcc90e7a80d.tar.xz
cuberite-cc13cbbe3d3a95735ca037f7382ffbcc90e7a80d.tar.zst
cuberite-cc13cbbe3d3a95735ca037f7382ffbcc90e7a80d.zip
Diffstat (limited to 'src')
-rw-r--r--src/com/mcserver/MCServerActivity.java76
1 files changed, 63 insertions, 13 deletions
diff --git a/src/com/mcserver/MCServerActivity.java b/src/com/mcserver/MCServerActivity.java
index f9bb363f4..f21c5f9d0 100644
--- a/src/com/mcserver/MCServerActivity.java
+++ b/src/com/mcserver/MCServerActivity.java
@@ -1,9 +1,14 @@
package com.mcserver;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
+import java.util.Timer;
+import java.util.TimerTask;
import android.app.Activity;
import android.graphics.Color;
@@ -17,6 +22,7 @@ import android.widget.TextView;
public class MCServerActivity extends Activity {
MainThread mThread = null;
Thread ServerStatusThread = null;
+ boolean mbExiting = false;
/** Called when the activity is first created. */
@Override
@@ -24,6 +30,9 @@ public class MCServerActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
+ Log.e("MCServer", "p id: " + android.os.Process.myPid() );
+
+
((Button)findViewById(R.id.start_server)).setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
if( mThread == null || mThread.isAlive() == false ) {
@@ -61,6 +70,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());
}
@@ -118,6 +172,14 @@ public class MCServerActivity extends Activity {
+ public void onDestroy() {
+ mbExiting = true;
+ super.onDestroy();
+ }
+
+
+
+
public void AddToLog( String logMessage ) {
@@ -128,7 +190,7 @@ public class MCServerActivity extends Activity {
public void SetText( final String aText ) {
- Log.d("MCServer", "in SetText " + aText);
+ //Log.d("MCServer", "in SetText " + aText);
/*
final MCServerActivity context = this;
this.runOnUiThread(new Runnable()
@@ -179,18 +241,6 @@ class MainThread extends Thread {
MainThread( MCServerActivity 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() {
mContext.NativeOnCreate();