安卓基于WifiScanner的签到APP

时间:2022-08-06 19:59:44

没图说个JB?首先上图:

安卓基于WifiScanner的签到APP 安卓基于WifiScanner的签到APP 安卓基于WifiScanner的签到APP 安卓基于WifiScanner的签到APP 安卓基于WifiScanner的签到APP

友情提醒:后台数据库使用的是Bmob后端云

主要设计思路:首先选一个附近的wifi,输入签到码,进行签到。

       签到之后会启动一个后台线程每隔一段时间扫描附近wifi,检测扫描范围内,是否存在之前签到时选择的wifi。

       若不存在,那么就会往数据库塞一条中途离场信息。

安卓基于WifiScanner的签到APP

这是工程的主要目录,包。

嗯对的,首先是AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.b140414.njupt.checkins">

    <!-- 允许联网 -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- 获取GSM(2g)、WCDMA(联通3g)等网络状态的信息 -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- 获取wifi网络状态的信息 -->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <!-- 保持CPU 运转,屏幕和键盘灯有可能是关闭的,用于文件上传和下载 -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <!-- 获取sd卡写的权限,用于文件上传和下载 -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- 允许读取手机状态 用于创建BmobInstallation -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".MainActivity" />
        <activity android:name=".Register" />

        <service android:name="service.WifiCheck_ch" />

        <activity android:name=".ScanActivity"></activity>
    </application>

</manifest>

登录界面:

activity_login.XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.b140414.njupt.checkins.LoginActivity"
    android:background="@drawable/background">
    <Button
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:text="登录"
        android:id="@+id/button_login"
        android:textSize="20dp"
        android:onClick="login_btn"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:background="#00000000"
        android:layout_above="@+id/button"
        android:layout_centerHorizontal="true" />

    <Button
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:id="@+id/button_re"
        android:textSize="15dp"
        android:background="@android:drawable/ic_menu_edit"
        android:onClick="register_btn"
        android:layout_alignTop="@+id/button"
        android:layout_alignParentStart="true" />

    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:id="@+id/imageView"
        android:src="@drawable/logo"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <RelativeLayout
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:id="@+id/relativeLayout"
        android:layout_marginTop="62dp"
        android:layout_below="@+id/imageView"
        android:layout_centerHorizontal="true">

        <EditText
            android:layout_width="120dp"
            android:layout_height="30dp"
            android:id="@+id/account_et"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:textSize="15dp"
            android:background="@drawable/abc_textfield_search_material"
            android:phoneNumber="true"
            android:layout_alignParentTop="true"
            android:layout_toEndOf="@+id/imageView2" />

        <EditText
            android:layout_width="120dp"
            android:layout_height="30dp"
            android:id="@+id/password_et"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:textSize="15dp"
            android:background="@drawable/abc_textfield_search_material"
            android:password="true"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_marginRight="30dp" />

        <ImageView
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:id="@+id/imageView2"
            android:background="@drawable/user"
            android:layout_marginRight="5dp"
            android:layout_alignBottom="@+id/account_et"
            android:layout_alignStart="@+id/imageView4" />

        <ImageView
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:id="@+id/imageView4"
            android:layout_alignBottom="@+id/password_et"
            android:layout_toStartOf="@+id/password_et"
            android:layout_marginRight="5dp"
            android:background="@drawable/lock" />
    </RelativeLayout>

    <Button
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:id="@+id/button"
        android:background="@android:drawable/ic_delete"
        android:textSize="15dp"
        android:onClick="quit_login_btn"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_above="@+id/textView"
        android:layout_alignParentEnd="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="注册"
        android:id="@+id/textView"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true"
        android:textColor="@color/abc_primary_text_disable_only_material_dark" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="退出"
        android:id="@+id/textView4"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:textColor="@color/abc_primary_text_disable_only_material_dark" />

    <ImageView
        android:layout_width="100dp"
        android:layout_height="30dp"
        android:id="@+id/imageView6"
        android:layout_below="@+id/imageView"
        android:layout_centerHorizontal="true"
        android:src="@drawable/qiandao" />

    <RadioGroup
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/RadioGroup_type"
        android:orientation="horizontal"
        android:layout_below="@+id/relativeLayout"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="38dp">
        <RadioButton
            android:layout_width="60dp"
            android:layout_height="wrap_content"
            android:text="学生"
            android:id="@+id/radioButton_s"
            android:checked="true"
            android:layout_marginTop="0dp"
            android:textColor="@color/abc_primary_text_disable_only_material_dark" />

        <RadioButton
            android:layout_width="60dp"
            android:layout_height="wrap_content"
            android:text="老师"
            android:id="@+id/radioButton_t"
            android:checked="false"

            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:layout_marginTop="0dp" />
    </RadioGroup>

</RelativeLayout>

LoginActivity:

package com.b140414.njupt.checkins;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import bmob_table.User;
import java.util.List;

import cn.bmob.v3.Bmob;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.listener.FindListener;

public class LoginActivity extends AppCompatActivity {

    private EditText account_et;
    private EditText password_et;
    private RadioGroup radioGroup;
    private RadioButton radioButton_s,radioButton_t;
    private String userType = "s";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        Bmob.initialize(this, "502aa80df90be300b2af61b48838cc90");

        account_et=(EditText)findViewById(R.id.account_et);
        password_et=(EditText)findViewById(R.id.password_et);
        radioGroup = (RadioGroup)findViewById(R.id.RadioGroup_type);
        radioButton_s = (RadioButton)findViewById(R.id.radioButton_s);
        radioButton_t = (RadioButton)findViewById(R.id.radioButton_t);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if(checkedId == radioButton_t.getId()){
                    userType = "t";
                }
                else {
                    if (checkedId == radioButton_s.getId()) {
                        userType = "s";
                    }
                    else {

                    }
                }

            }
        });
    }

    //登录按钮响应事件
    public void login_btn(View view){
        final String account=account_et.getText().toString();
        final String password=password_et.getText().toString();

        if(account.equals("")){
            Toast.makeText(LoginActivity.this, "请输入您的手机号!", Toast.LENGTH_LONG).show();
        }
        else if(password.equals("")){
            Toast.makeText(LoginActivity.this,"请输入您的密码!",Toast.LENGTH_LONG).show();
        }else {
            BmobQuery<User> query=new BmobQuery<>();
            query.addWhereEqualTo("account",account);
            query.findObjects(LoginActivity.this,new FindListener<User>() {
                @Override
                public void onSuccess(List<User> users) {
                    if(users.size()==0){
                        Toast.makeText(LoginActivity.this,"账户不存在!",Toast.LENGTH_LONG).show();
                        return;
                    }
                    for(User a:users){
                        if(!a.getPassword().equals(password)) {
                            Toast.makeText(LoginActivity.this, "账户或密码有误,请重新输入!", Toast.LENGTH_LONG).show();
                            return;
                        }

                        else{
                            if(userType.equals("t")) {
                                Intent intent = new Intent();
                                intent.setClass(LoginActivity.this, MainActivity.class);
                                intent.putExtra("account", account);
                                intent.putExtra("realName", a.getRealName());

                                startActivity(intent);
                            }
                            else {
                                if(userType.equals("s")){
                                    Intent intent = new Intent();
                                    intent.setClass(LoginActivity.this, ScanActivity.class);
                                    intent.putExtra("account", account);
                                    intent.putExtra("realName", a.getRealName());
                                    startActivity(intent);
                                }
                                else {
                                    Toast.makeText(LoginActivity.this, "请选择正确的用户类型", Toast.LENGTH_LONG).show();
                                }
                            }
                        }
                    }

                }

                @Override
                public void onError(int i, String s) {
                    Toast.makeText(LoginActivity.this,"登录失败",Toast.LENGTH_LONG).show();
                }
            });
        }
    }

    //注册按钮响应事件
    public void register_btn(View view) {
        Intent intent=new Intent();
        intent.setClass(LoginActivity.this,Register.class);
        startActivity(intent);
    }

    //退出按钮响应事件
    public void quit_login_btn(View view) {
        finish();
    }
}

注册界面:

activity_register.XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.b140414.njupt.checkins.Register"
    android:background="@drawable/background">

    <ImageView
        android:layout_width="100dp"
        android:layout_height="70dp"
        android:id="@+id/imageView3"
        android:src="@drawable/logo"
        android:layout_alignParentTop="true"
        android:layout_toStartOf="@+id/imageView7" />

    <Button
        android:layout_width="200dp"
        android:layout_height="60dp"
        android:text="注册"
        android:id="@+id/button_queding"
        android:background="@drawable/abc_ab_share_pack_mtrl_alpha"
        android:textSize="20dp"
        android:onClick="register_sure"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_below="@+id/relativeLayout2"
        android:layout_marginTop="20dp"
        android:layout_alignEnd="@+id/relativeLayout2"
        android:layout_alignStart="@+id/relativeLayout2" />

    <Button
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:id="@+id/button_tuichu"
        android:background="@android:drawable/ic_menu_revert"
        android:textSize="20dp"
        android:onClick="register_quit_btn"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_above="@+id/textView_back"
        android:layout_alignParentEnd="true" />

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="150dp"
        android:id="@+id/relativeLayout2"
        android:layout_marginTop="63dp"
        android:layout_below="@+id/imageView3"
        android:layout_centerHorizontal="true">

        <EditText
            android:layout_width="150dp"
            android:layout_height="25dp"
            android:id="@+id/register_account_et"
            android:background="@drawable/abc_textfield_search_material"
            android:phoneNumber="true"
            android:layout_marginLeft="10dp"
            android:layout_alignParentTop="true"
            android:layout_toEndOf="@+id/textView3"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:textSize="15dp" />

        <EditText
            android:layout_width="150dp"
            android:layout_height="25dp"
            android:id="@+id/register_password_et"
            android:background="@drawable/abc_textfield_search_material"
            android:password="true"
            android:layout_marginLeft="0dp"
            android:layout_below="@+id/register_account_et"
            android:layout_alignStart="@+id/register_account_et"
            android:layout_marginTop="10dp"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:textSize="15dp" />

        <EditText
            android:layout_width="150dp"
            android:layout_height="25dp"
            android:id="@+id/password_again_et"
            android:background="@drawable/abc_textfield_search_material"
            android:password="true"
            android:layout_marginLeft="0dp"
            android:layout_below="@+id/register_password_et"
            android:layout_alignStart="@+id/register_password_et"
            android:layout_marginTop="10dp"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:textSize="15dp" />

        <EditText
            android:layout_width="150dp"
            android:layout_height="25dp"
            android:id="@+id/realName_et"
            android:background="@drawable/abc_textfield_search_material"
            android:layout_marginLeft="0dp"
            android:layout_below="@+id/password_again_et"
            android:layout_alignStart="@+id/password_again_et"
            android:layout_marginTop="10dp"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:textSize="15dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="再输密码:"
            android:id="@+id/textView3"
            android:textSize="15dp"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:layout_marginLeft="0dp"
            android:layout_above="@+id/realName_et"
            android:layout_alignParentStart="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="姓名:"
            android:id="@+id/textView_x"
            android:textSize="15dp"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:layout_marginLeft="0dp"
            android:layout_alignBottom="@+id/realName_et"
            android:layout_alignParentStart="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密码:"
            android:id="@+id/textView_m"
            android:textSize="15dp"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:layout_marginLeft="0dp"
            android:layout_alignBottom="@+id/register_password_et"
            android:layout_alignParentStart="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="手机号:"
            android:id="@+id/textView_z"
            android:textSize="15dp"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:layout_marginLeft="0dp"
            android:layout_marginRight="5dp"
            android:layout_above="@+id/register_password_et"
            android:layout_alignParentStart="true" />
    </RelativeLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="返回"
        android:id="@+id/textView_back"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_marginLeft="6dp"
        android:layout_alignParentBottom="true"
        android:layout_alignStart="@+id/button_tuichu" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView7"
        android:src="@drawable/signup"
        android:layout_alignBottom="@+id/imageView3"
        android:layout_alignEnd="@+id/relativeLayout2" />

</RelativeLayout>

Register:

package com.b140414.njupt.checkins;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import bmob_table.User;

import cn.bmob.v3.listener.SaveListener;

public class Register extends AppCompatActivity {

    private EditText register_account_et;
    private EditText register_password_et;
    private EditText password_again_et;
    private EditText realName_et;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        register_account_et= (EditText) findViewById(R.id.register_account_et);
        register_password_et=(EditText)findViewById(R.id.register_password_et);
        password_again_et=(EditText)findViewById(R.id.password_again_et);
        realName_et=(EditText)findViewById(R.id.realName_et);
    }

    public void register_sure(View view){
        String register_password=register_password_et.getText().toString();
        String password_again=password_again_et.getText().toString();
        String register_account=register_account_et.getText().toString();
        String realName=realName_et.getText().toString();

        if(!register_password.equals(password_again)){
            Toast.makeText(Register.this,"两次输入的密码不一致,请重新输入!",Toast.LENGTH_LONG).show();
        }
        else if(register_account.isEmpty()||register_account.length()!=11){
            Toast.makeText(Register.this,"输入手机号不合法,请重新输入!",Toast.LENGTH_LONG).show();
        }else if(realName.isEmpty()){
            Toast.makeText(Register.this,"请输入您的真实姓名!",Toast.LENGTH_LONG).show();
        }else{
            User user=new User();
            user.setAccount(register_account);
            user.setPassword(password_again);
            user.setRealName(realName);

            user.save(Register.this,new SaveListener() {
                @Override
                public void onSuccess() {
                    Toast.makeText(Register.this,"注册成功,请返回登录!",Toast.LENGTH_LONG).show();
                }

                @Override
                public void onFailure(int i, String s) {
                    Toast.makeText(Register.this,"注册失败,请重试!",Toast.LENGTH_LONG).show();
                }
            });
        }

    }

    public void register_quit_btn(View view){
        finish();
    }
}

学生界面:

activity_scan.XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.b140414.njupt.checkins.ScanActivity"
    android:background="@drawable/background">

    <ListView
        android:layout_width="wrap_content"
        android:layout_height="120dp"
        android:id="@+id/listView"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true" />

    <Button
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:text="刷新"
        android:id="@+id/button3"
        android:onClick="netScan"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:background="@drawable/circle"
        android:layout_below="@+id/listView"
        android:layout_centerHorizontal="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="请选择一个wifi"
        android:id="@+id/textView_choice"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_below="@+id/Wifi_name"
        android:layout_centerHorizontal="true" />

    <Button
        android:layout_width="100dp"
        android:layout_height="40dp"
        android:text="签到"
        android:id="@+id/Scan_check"
        android:onClick="Scan_Dao"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:background="@drawable/circle"
        android:layout_alignTop="@+id/button_scaninfo"
        android:layout_toStartOf="@+id/Wifi_name" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/Wifi_name"
        android:layout_below="@+id/button3"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="100dp"
        android:textColor="@color/abc_primary_text_disable_only_material_dark" />

    <Button
        android:layout_width="100dp"
        android:layout_height="40dp"
        android:text="签退并退出"
        android:id="@+id/button_scanquit"
        android:onClick="Scanquit"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:background="@drawable/circle"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <Button
        android:layout_width="100dp"
        android:layout_height="40dp"
        android:text="本人记录"
        android:id="@+id/button_scaninfo"
        android:onClick="Info_ScanDao"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:background="@drawable/circle"
        android:layout_marginTop="27dp"
        android:layout_below="@+id/textView_choice"
        android:layout_alignStart="@+id/Wifi_name" />

    <EditText
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:id="@+id/editText_s_key"
        android:background="@drawable/abc_textfield_search_material"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_below="@+id/textView7"
        android:layout_centerHorizontal="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="签到口令"
        android:id="@+id/textView7"
        android:textSize="20dp"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_below="@+id/button3"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp" />
</RelativeLayout>

ScanActivity:

package com.b140414.njupt.checkins;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import bmob_table.User;

import cn.bmob.v3.listener.SaveListener;

public class Register extends AppCompatActivity {

    private EditText register_account_et;
    private EditText register_password_et;
    private EditText password_again_et;
    private EditText realName_et;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        register_account_et= (EditText) findViewById(R.id.register_account_et);
        register_password_et=(EditText)findViewById(R.id.register_password_et);
        password_again_et=(EditText)findViewById(R.id.password_again_et);
        realName_et=(EditText)findViewById(R.id.realName_et);
    }

    public void register_sure(View view){
        String register_password=register_password_et.getText().toString();
        String password_again=password_again_et.getText().toString();
        String register_account=register_account_et.getText().toString();
        String realName=realName_et.getText().toString();

        if(!register_password.equals(password_again)){
            Toast.makeText(Register.this,"两次输入的密码不一致,请重新输入!",Toast.LENGTH_LONG).show();
        }
        else if(register_account.isEmpty()||register_account.length()!=11){
            Toast.makeText(Register.this,"输入手机号不合法,请重新输入!",Toast.LENGTH_LONG).show();
        }else if(realName.isEmpty()){
            Toast.makeText(Register.this,"请输入您的真实姓名!",Toast.LENGTH_LONG).show();
        }else{
            User user=new User();
            user.setAccount(register_account);
            user.setPassword(password_again);
            user.setRealName(realName);

            user.save(Register.this,new SaveListener() {
                @Override
                public void onSuccess() {
                    Toast.makeText(Register.this,"注册成功,请返回登录!",Toast.LENGTH_LONG).show();
                }

                @Override
                public void onFailure(int i, String s) {
                    Toast.makeText(Register.this,"注册失败,请重试!",Toast.LENGTH_LONG).show();
                }
            });
        }

    }

    public void register_quit_btn(View view){
        finish();
    }
}

教师界面:

activity_main.XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.b140414.njupt.checkins.MainActivity"
    android:background="@drawable/background">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="欢迎使用"
        android:id="@+id/textView_title"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:textSize="20dp"
        android:textColor="@color/abc_primary_text_disable_only_material_dark" />

    <Button
        android:layout_width="150dp"
        android:layout_height="40dp"
        android:text="退出"
        android:id="@+id/button_tui"
        android:background="@drawable/circle"
        android:textSize="15dp"
        android:onClick="Quit"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_marginBottom="47dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/hello"
        android:textSize="15dp"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="40dp"
        android:layout_below="@+id/textView_title"
        android:layout_alignParentStart="true" />

    <RelativeLayout
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:id="@+id/relativeLayout3"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="135dp">

        <Button
            android:layout_width="100dp"
            android:layout_height="30dp"
            android:text="离场信息"
            android:id="@+id/button_li"
            android:background="@drawable/circle"
            android:textSize="15dp"
            android:onClick="LiChang"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true" />

        <Button
            android:layout_width="100dp"
            android:layout_height="30dp"
            android:text="点名"
            android:id="@+id/button_call"
            android:background="@drawable/circle"
            android:textSize="15dp"
            android:onClick="call"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:layout_alignParentBottom="true"
            android:layout_alignParentStart="true" />

        <EditText
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/editText_key"
            android:background="@drawable/abc_textfield_search_material"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:layout_below="@+id/textView6"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="签到口令"
            android:id="@+id/textView6"
            android:textSize="20dp"
            android:textColor="@color/abc_primary_text_disable_only_material_dark"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true" />
    </RelativeLayout>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView5"
        android:src="@drawable/qiandao"
        android:layout_marginLeft="-20dp"
        android:layout_above="@+id/hello"
        android:layout_toEndOf="@+id/textView_title" />

    <ListView
        android:layout_width="wrap_content"
        android:layout_height="120dp"
        android:id="@+id/listView2"
        android:layout_below="@+id/hello" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:text="刷新"
        android:id="@+id/button2"
        android:onClick="netScan_t"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:background="@drawable/circle"
        android:layout_below="@+id/listView2"
        android:layout_alignParentStart="true"
        android:layout_marginTop="20dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="请选择一个wifi"
        android:id="@+id/textView_BSSID"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_alignBottom="@+id/button2"
        android:layout_alignEnd="@+id/listView2" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/textView_SSID"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:layout_above="@+id/textView_BSSID"
        android:layout_toEndOf="@+id/relativeLayout3"
        android:layout_marginStart="11dp" />

</RelativeLayout>

MainActivity:

package com.b140414.njupt.checkins;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import bmob_table.Leave_table;
import bmob_table.ScanCheck;
import service.WifiCheck_ch;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.listener.FindListener;

public class MainActivity extends AppCompatActivity {

    private TextView hello;
    public static String BSSID;
    public String realName ;
    public String account ;
    private List<Leave_table> leave_half = new ArrayList<Leave_table>();
    private Intent bindIntent;
    private WifiManager wifiManager;
    private ListView listView;
    private  TextView textview_choice;
    private  TextView textview_wifiname;
    private  String Key;
    private EditText editText_key;

    TextView text1;
    TextView text2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        hello = (TextView) findViewById(R.id.hello);
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        realName = bundle.getString("realName");
        account = bundle.getString("account");
        hello.setText("你好," + realName);
        //BindService传入账号与姓名信息
        bindIntent = new Intent(MainActivity.this,WifiCheck_ch.class);
        bindIntent.putExtra("account",account);
        bindIntent.putExtra("name",realName);
        listView = (ListView)findViewById(R.id.listView2);
        textview_choice = (TextView)findViewById(R.id.textView_BSSID);
        textview_wifiname = (TextView)findViewById(R.id.textView_SSID);
        editText_key = (EditText)findViewById(R.id.editText_key);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> l, View v, int position,long id) {
                text1=(TextView)v.findViewById(R.id.BSSID);
                text2=(TextView)v.findViewById(R.id.SSID);
                BSSID = text1.getText().toString();
                textview_choice.setText(BSSID);
                textview_wifiname.setText(text2.getText().toString());
            }
        });

        wifiManager =  (WifiManager)getSystemService(Context.WIFI_SERVICE);

    }

    //获取MAC
    public String getLocalMacAddress() {
        WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        WifiInfo info = wifi.getConnectionInfo();
        return info.getMacAddress();
    }

    //获取链接的wifi的MAC地址
    public String getLinkMacAddress() {
        WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        WifiInfo info = wifi.getConnectionInfo();
        return info.getBSSID();
    }

    //点名按钮事件
    public void call(View view){
        BmobQuery<ScanCheck> query1 = new BmobQuery<>();
        BmobQuery<ScanCheck> query2 = new BmobQuery<>();
        BmobQuery<ScanCheck> query3 = new BmobQuery<>();
        Key = editText_key.getText().toString();
        //获取当前时间
        Date todaydate=new Date();
        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
        final String s = format.format(todaydate);
        //当前时间与check_table表中的签到时间进行匹配
            //query1.addWhereEqualTo("DaoTime", s);
            query2.addWhereEqualTo("BSSID", BSSID);
            query3.addWhereEqualTo("Key",Key);
            List<BmobQuery<ScanCheck>> andQuerys = new ArrayList<BmobQuery<ScanCheck>>();
            andQuerys.add(query1);
            andQuerys.add(query2);
            andQuerys.add(query3);
            BmobQuery<ScanCheck> query_and = new BmobQuery<>();
            query_and.and(andQuerys);
            query_and.findObjects(MainActivity.this, new FindListener<ScanCheck>() {
                @Override
                public void onSuccess(List<ScanCheck> qianDao) {

                    String str = "";
                    for (ScanCheck a : qianDao) {
                        str += a.getRealName() + "\n\n";
                    }
                    String str1 = "查询成功:共" + qianDao.size() + "个人签到。";
                    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                    builder.setTitle(s +"\n"+ Key + "的签到人员详情");
                    builder.setMessage(str + str1);
                    builder.create().show();
                }

                @Override
                public void onError(int i, String s) {
                    Toast.makeText(MainActivity.this, "查询失败!" + s, Toast.LENGTH_LONG);
                }
            });

    }

    //查看离场信息
    public void LiChang(View view) {
        BmobQuery<Leave_table> query2 = new BmobQuery<>();
        BmobQuery<Leave_table> query1 = new BmobQuery<>();
        //获取当前时间
        Date todaydate = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String s = format.format(todaydate);
        //当前时间与leave_table表中的leavetype+时间 && BSSID 进行匹配
        query2.addWhereEqualTo("LeaveType", "中途离场"+s);
        query1.addWhereEqualTo("BSSID", BSSID);

        List<BmobQuery<Leave_table>> andQuerys = new ArrayList<BmobQuery<Leave_table>>();
        andQuerys.add(query1);
        andQuerys.add(query2);
        BmobQuery<Leave_table> query_and = new BmobQuery<>();
        query_and.and(andQuerys);
        query_and.findObjects(MainActivity.this, new FindListener<Leave_table>() {
            @Override
            public void onSuccess(List<Leave_table> leave) {
                String str = "";
                for (Leave_table sjk : leave) {
                    Boolean hasName = false;
                    for(Leave_table bd : leave_half){
                        if(sjk.getRealName().equals(bd.getRealName())) {
                            hasName = true;
                            break;
                        }
                    }
                    if(!hasName){
                        leave_half.add(sjk);
                    }

                }
                for (Leave_table a : leave_half) {
                    str += a.getRealName() + "\n\n";
                }
                String str1 = "查询成功:共" + leave_half.size() + "个人中途离场。";
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                Date todaydate = new Date();
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                String s = format.format(todaydate);
                builder.setTitle(s + "的中途离场人员详情");
                builder.setMessage(str + str1);
                builder.create().show();
            }

            @Override
            public void onError(int i, String s) {
                Toast.makeText(MainActivity.this, "查询失败!" + s, Toast.LENGTH_LONG);
            }
        });
    }

    public void Quit(View view) {
        finish();
    }
    public void netScan_t(View v){
        List<Map<String, Object>> list;
        //启动扫描
        wifiManager.startScan();

        //获取扫描结果
        list = getListForSimpleAdapter();

        SimpleAdapter adapter = new SimpleAdapter(this, list,
                R.layout.wifiinfo,
                new String[] { "SSID", "BSSID" },
                new int[] { R.id.SSID,R.id.BSSID });

        listView.setAdapter(adapter);

    }

    private List<Map<String, Object>> getListForSimpleAdapter() {
        List<ScanResult> mData= wifiManager.getScanResults();
        List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();

        for (ScanResult a : mData) {
            Map<String, Object> map = new HashMap<String, Object>();
            map = new HashMap<String, Object>();
            map.put("SSID", a.SSID);
            map.put("BSSID", a.BSSID);

            list.add(map);
        }
        return list;
    }
}

至于界面的图片啊啥的,可以去git上下载我的整个工程来获取:https://github.com/ZzzSimon/Checkins

未完待续……