E energeticaserranopolis New Member Licensed User Longtime User May 5, 2015 #1 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.
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.
Erel B4X founder Staff member Licensed User Longtime User May 6, 2015 #2 B4X: Dim r As Reflector Log(r.RunStaticMethod("android.os.Build", "getString", Array("net.hostname"), Array As String("java.lang.String"))) Upvote 0
B4X: Dim r As Reflector Log(r.RunStaticMethod("android.os.Build", "getString", Array("net.hostname"), Array As String("java.lang.String")))
M manuel-r Member Licensed User Longtime User May 12, 2016 #3 Hi Erel, hi all ...and how can I set net.hostname by reflector or javaobject? Thank you. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User May 13, 2016 #4 It is not possible to change the hostname programmatically (at least not on unrooted devices). Upvote 0