Android Question net.hostname with reflector

Discussion in 'Android Questions' started by energeticaserranopolis, May 5, 2015.

  1. energeticaserranopolis

    energeticaserranopolis New Member Licensed User

    Hello, I found this code that returns the net.hostname. I need to adapt it for use with B4a.
    Can anyone help me?

    Public static String getHostName(String defValue) {
    Try {
    Method getString = Build.class.getDeclaredMethod("getString", String.class);
    getString.setAccessible(True);
    Return getString.invoke(Null, "net.hostname").toString();
    } catch (Exception ex) {
    return defValue;
    }
    }


    Thank you.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Dim r As Reflector
    Log(r.RunStaticMethod("android.os.Build""getString"Array("net.hostname"), Array As String("java.lang.String")))
     
  3. manuel-r

    manuel-r Member Licensed User

    Hi Erel, hi all

    ...and how can I set net.hostname by reflector or javaobject? Thank you.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible to change the hostname programmatically (at least not on unrooted devices).
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice