Android develops and implements a method to obtain local IP address under WiFi

This paper describes the method of Android development to obtain the local IP address under WiFi. Share with you for your reference, as follows:

Introduction to core code:

The WiFi manager class provides the management of device WiFi functions, including turning on and off WiFi switches, obtaining IP addresses, etc. early Android versions even support IP settings. Here we only introduce its simple small application - obtaining IP address.

First, add uses permission: change_ WIFI_ STATE,WAKE_ Lock and access_ WIFI_ STATE。 The code is as follows (androidmanifest. XML):

Java code:

More readers interested in Android related content can view the special topics of this site: summary of Android hardware related operation and application, summary of Android resource operation skills, summary of Android view skills, introduction and advanced tutorial of Android development and summary of Android control usage

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>