[Note] Sign in to the app Android client (Open Source) and app android
[Note] Sign in to the app, Android client, and server using the Bmob service, and sign in using the MAC address of office wifi. Author: JKXQJ
1. The reason for doing this app: The company administration told me this Friday that I did not sign in many times in July, so I decided to take time out on weekends to create a sign-in app Based on the vromac mac address.
2. I drew a sketch at the company that afternoon to prepare for the weekend.
3. In fact, this app is very simple. After the bmob service is used in the background, the development efficiency doubles and it will be made in half a day.
As follows:
4. The core code is as follows:
// Check what network is connected public Integer checkWifi (Context context) {ConnectivityManager = (ConnectivityManager) context. getSystemService (Context. CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = ConnectivityManager. getActiveNetworkInfo (); if (mNetworkInfo. getState () = NetworkInfo. state. CONNECTED) {if (mNetworkInfo. getType () = ConnectivityManager. TYPE_MOBILE) {return 1; // return 1, connected to a mobile network} Else if (mNetworkInfo. getType () = ConnectivityManager. TYPE_WIFI) {return 2; // return 2, connected to wifi} else {return 3; // return 3, no connection.} Return 3;} // obtain the IP public String getLocalIpAddress () {try {for (Enumeration <NetworkInterface> en = NetworkInterface. getNetworkInterfaces (); en. hasMoreElements ();) {NetworkInterface intf = en. nextElement (); for (Enumeration <InetAddress> enumIpAddr = intf. getInetAddresses (); enumIpAddr. hasMoreElements ();) {InetAddress inetAddress = enumIpAddr. nextElement (); if (! InetAddress. isLoopbackAddress () {return inetAddress. getHostAddress (). toString () ;}}} catch (SocketException ex) {Log. e ("IP Address:", ex. toString ();} return null;} // obtain MAC public String getLocalMacAddress () {WifiManager wifi = (WifiManager) getSystemService (Context. WIFI_SERVICE); WifiInfo = wifi. getConnectionInfo (); return info. getMacAddress ();}
5. The project has been uploaded to github. Welcome to watch/fork/star/download.
Https://github.com/jkxqj/BianQian
Csdn code address:
Https://code.csdn.net/acmjk/bianqian
Copyright Disclaimer: This article is an original article by the blogger. For more information, see this blog address! Look to the master, follow the master, walk with the master, see through the master, become the master.