Get Hostname from Local Host - Android Network

Android examples for Network:IP Address

Description

Get Hostname from Local Host

Demo Code


import android.net.Uri;
import java.io.*;

public class Main{
    static String GetHostname() {
        try {//w  w  w. j a  va  2  s.co  m
            String hostname = new String(java.net.InetAddress
                    .getLocalHost().getHostName());
            return hostname;
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return "";
    }
}

Related Tutorials