- Home /
Answer by daniel glenn · Jul 03, 2012 at 02:03 AM
you need to import the java net package before you can run this basic example:
try{
InetAddress ownIP=InetAddress.getLocalHost();
System.out.println("IP of my Device := "+ownIP.getHostAddress());
}catch (Exception e){
System.out.println("Exception caught ="+e.getMessage());
}
hope it helps, have a nice day
thanks but i seem to be getting errors when i try to import java net package ? would you please tell me how to import it into unity ? thanks
import java.net; gives me The type or namespace name `java' could not be found. Are you missing a using directive or an assembly reference?
sorry for my late feedback. I have big account issue with the new UDN community. Use import java[dot]net[dot][star]; to import all package. Probably you need to import java[dot]util[dot][star];
[dot] equal .
[star] equal *
A good link for this: http://marakana.com/bookshelf/java_fundamentals_tutorial/java_net.html
sorry for this [dot [star]..blabla the url forum parser is a pain in the a**
Answer by daniel glenn · Jul 03, 2012 at 03:03 AM
IP adress, using the WifiManager from android:
TextView tv = (TextView) findViewById(R.id.tv);
WifiManager wim= (WifiManager) getSystemService(WIFI_SERVICE);
List<WifiConfiguration> l = wim.getConfiguredNetworks();
WifiConfiguration wc = l.get(0);
tv.append("\n"+ Formatter.formatIpAddress(wim.getConnectionInfo().getIpAddress()));
Hope it helps, have nice day
What using statements did you add to resolve Wifi$$anonymous$$anager?
Dear $$anonymous$$,
I am utterly interested how on earth can you import java.net into Unity 5.2 that I am using. or the Wifi$$anonymous$$anager... I have checked the link you posted above, but still couldnt figure it out, even after a whole day of googling... im sure I am missing a core knowledge. I know that this is pretty much a dead thread, but if you dont $$anonymous$$d, could you please let me know how can I get with or without java.net* the IP on an Android through C# unity?
would make my day!! thanks, $$anonymous$$ornel
Your answer
Follow this Question
Related Questions
Perform DNS Lookup To Get IP Address 1 Answer
Networking ? 2 Answers
Adding server's ip address to favorites so that I don't have to type it in all the time? 1 Answer
I can't open unity community page 0 Answers
android version of a pc game 1 Answer