summaryrefslogtreecommitdiff
path: root/same-android
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-27 14:25:48 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-27 14:25:48 +0100
commita1abc25b91760fce29c0bd94f60e1ee592a151cc (patch)
treeb7a5c78cb098b5befb3ebdeca3e249ac43d0b9ba /same-android
parent2570d2c6f0be6bb16630b5685063501dd931b4d2 (diff)
Show device IP address.
Diffstat (limited to 'same-android')
-rw-r--r--same-android/res/layout/main.xml14
-rw-r--r--same-android/src/main/java/com/orbekk/HelloAndroidActivity.java10
2 files changed, 23 insertions, 1 deletions
diff --git a/same-android/res/layout/main.xml b/same-android/res/layout/main.xml
index a286b81..74674df 100644
--- a/same-android/res/layout/main.xml
+++ b/same-android/res/layout/main.xml
@@ -5,6 +5,13 @@
android:layout_height="fill_parent"
>
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Commands"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
@@ -19,4 +26,11 @@
android:onClick="joinNetwork"
android:text="Join" />
+ <TextView
+ android:id="@+id/ipAddress"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
</LinearLayout>
diff --git a/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java b/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
index a8ac1e5..81eebc4 100644
--- a/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
+++ b/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
@@ -3,8 +3,8 @@ package com.orbekk;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.orbekk.discovery.Broadcaster;
import com.orbekk.discovery.SameService;
-import com.orbekk.net.Broadcaster;
import com.orbekk.same.ClientApp;
import com.orbekk.same.ClientServiceImpl;
import com.orbekk.same.SameInterface;
@@ -14,6 +14,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
+import android.widget.TextView;
public class HelloAndroidActivity extends Activity {
private Logger logger = LoggerFactory.getLogger(getClass());
@@ -32,6 +33,12 @@ public class HelloAndroidActivity extends Activity {
startService(intent);
}
+ private void showIpAddress() {
+ TextView t = (TextView)findViewById(R.id.ipAddress);
+ t.setText("My IP: ");
+ t.append(new Broadcaster(this).getWlanAddress().getHostAddress());
+ }
+
/**
* Called when the activity is first created.
* @param savedInstanceState If the activity is being re-initialized after
@@ -46,6 +53,7 @@ public class HelloAndroidActivity extends Activity {
System.setProperty("java.net.preferIPv6Addresses", "false");
setContentView(R.layout.main);
+ showIpAddress();
// ClientApp client = new ClientApp();
// SameInterface client_ = client.getClient(10015, "ClientNetwork",