summaryrefslogtreecommitdiff
path: root/same-android/src/main/java/com
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/src/main/java/com
parent2570d2c6f0be6bb16630b5685063501dd931b4d2 (diff)
Show device IP address.
Diffstat (limited to 'same-android/src/main/java/com')
-rw-r--r--same-android/src/main/java/com/orbekk/HelloAndroidActivity.java10
1 files changed, 9 insertions, 1 deletions
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",