From c40af4c4ab0541638a6079a97c601a774ed65d02 Mon Sep 17 00:00:00 2001 From: faketruth Date: Fri, 17 Aug 2012 22:20:35 +0000 Subject: Android: Pressing back button sends stop command to server Android: ToJava can call functions on Java by using JNI Android: Plugins work Android: Added android specific files to VS2008 project, but they are excluded from compiling git-svn-id: http://mc-server.googlecode.com/svn/trunk@747 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- src/com/mcserver/MCServerActivity.java | 39 ++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'src/com/mcserver') diff --git a/src/com/mcserver/MCServerActivity.java b/src/com/mcserver/MCServerActivity.java index f7bfc76e3..ff1a4fae2 100644 --- a/src/com/mcserver/MCServerActivity.java +++ b/src/com/mcserver/MCServerActivity.java @@ -2,35 +2,42 @@ package com.mcserver; import android.app.Activity; import android.os.Bundle; +import android.util.Log; import android.view.KeyEvent; public class MCServerActivity extends Activity { + MainThread mThread = null; + /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); - MainThread p = new MainThread(); - p.start(); + mThread = new MainThread(); + mThread.start(); } - public boolean onKeyDown(int keyCode, KeyEvent event) - { + public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode==KeyEvent.KEYCODE_BACK) { //android.os.Process.killProcess(android.os.Process.myPid()); - NativeCleanUp(); + mThread.NativeCleanUp(); return super.onKeyDown(keyCode, event); } return false; } + public void AddToLog( String logMessage ) { + + } + static { System.loadLibrary("mcserver"); } - private static native void NativeCleanUp(); + + } @@ -39,9 +46,23 @@ class MainThread extends Thread { MainThread() { } + public void AddToLog( String logMessage ) { + //Log.d("MCServer", "Add to log: " + logMessage); + } + + public void TestTest(){ + Log.d("MCServer", "in testtest"); + } + public void run() { NativeOnCreate(); } - - private static native void NativeOnCreate(); -} \ No newline at end of file + public native void NativeOnCreate(); + public native void NativeCleanUp(); +} + + + + + + -- cgit v1.2.3