summaryrefslogtreecommitdiff
path: root/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-13 10:18:02 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-13 10:18:02 +0100
commitba7132f3ce5629cff2cc4857fff7bd672511bee8 (patch)
treedc6f7d1adafb8351004f2de6f3f775ebfe596fc7 /same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
parent85a93de08694f25bd049c5236f11f06b8d8e4ff7 (diff)
Rename projects.
– jsonrpc → same – master → same-android
Diffstat (limited to 'same-android/src/main/java/com/orbekk/HelloAndroidActivity.java')
-rw-r--r--same-android/src/main/java/com/orbekk/HelloAndroidActivity.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java b/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
new file mode 100644
index 0000000..4160bf4
--- /dev/null
+++ b/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
@@ -0,0 +1,49 @@
+package com.orbekk;
+
+import com.orbekk.net.Broadcaster;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+
+public class HelloAndroidActivity extends Activity {
+
+ private static String TAG = "master";
+ private PingServer pingServer;
+
+ /**
+ * Called when the activity is first created.
+ * @param savedInstanceState If the activity is being re-initialized after
+ * previously being shut down then this Bundle contains the data it most
+ * recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b>
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ System.setProperty("java.net.preferIPv4Stack", "true");
+ System.setProperty("java.net.preferIPv6Addresses", "false");
+
+ Log.i(TAG, "onCreate");
+ setContentView(R.layout.main);
+
+ pingServer = PingServer.createPingServer(10080);
+ try {
+ pingServer.start();
+ } catch (Exception e) {
+ throw new RuntimeException(e.getMessage());
+ }
+
+// Broadcast broadcast = new Broadcast(this);
+// broadcast.sendBroadcast("Broadcast test".getBytes(), 10010);
+ Broadcaster broadcaster = new Broadcaster();
+ Log.i(TAG, "Broadcast success: " + broadcaster.sendBroadcast(10010, "Broadcast test from Android".getBytes()));
+ }
+
+ @Override
+ protected void onDestroy() {
+ pingServer.stop();
+ super.onDestroy();
+ }
+}
+