[Note] Sign in to the app Android client (Open Source) and app android

Source: Internet
Author: User

[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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.