show ip works, but looks
This commit is contained in:
@@ -25,6 +25,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private static final int SAMPLE_RATE = 8000;
|
private static final int SAMPLE_RATE = 8000;
|
||||||
@@ -36,11 +38,32 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private final List<Socket> clients = new ArrayList<>();
|
private final List<Socket> clients = new ArrayList<>();
|
||||||
|
|
||||||
|
private String getLocalIpAddress() {
|
||||||
|
try {
|
||||||
|
for (java.util.Enumeration<java.net.NetworkInterface> en = java.net.NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
|
||||||
|
java.net.NetworkInterface intf = en.nextElement();
|
||||||
|
for (java.util.Enumeration<java.net.InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
||||||
|
java.net.InetAddress inetAddress = enumIpAddr.nextElement();
|
||||||
|
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof java.net.Inet4Address) {
|
||||||
|
return inetAddress.getHostAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return "unbekannt";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
TextView ipAddressText = findViewById(R.id.ipAddressText);
|
||||||
|
String ip = getLocalIpAddress();
|
||||||
|
ipAddressText.setText("Sever(Kinder)-IP-Adresse: " + ip);
|
||||||
|
|
||||||
Button startStreamButton = findViewById(R.id.startStreamButton);
|
Button startStreamButton = findViewById(R.id.startStreamButton);
|
||||||
|
|
||||||
startStreamButton.setOnClickListener(v -> {
|
startStreamButton.setOnClickListener(v -> {
|
||||||
|
|||||||
@@ -10,4 +10,22 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Start Streaming"/>
|
android:text="Start Streaming"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ipAddressText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="IP-Adresse: wird geladen..."
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@android:color/black" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/PortText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="Port zu wählen: 50005"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@android:color/black" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user