• 第二阶段冲刺七


    这是一个关于登陆进入对应用户界面的几个功能。

    package com.example.shazidouhuiapp.activity;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.Toast;
    
    import androidx.annotation.Nullable;
    import androidx.appcompat.app.AppCompatActivity;
    
    import com.example.shazidouhuiapp.Bean.User;
    import com.example.shazidouhuiapp.MainActivity;
    import com.example.shazidouhuiapp.R;
    
    import java.util.Timer;
    import java.util.TimerTask;
    
    import cn.bmob.v3.Bmob;
    import cn.bmob.v3.BmobQuery;
    import cn.bmob.v3.BmobUser;
    import cn.bmob.v3.exception.BmobException;
    import cn.bmob.v3.listener.QueryListener;
    
    public class splash extends AppCompatActivity {
        @Override
        protected void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.splash);
            Timer timer = new Timer();
            timer.schedule(timertask, 2000);
            Bmob.initialize(this,"e575c228703fd6ae7b822919edc18236");
        }
    
        TimerTask timertask = new TimerTask() {
            @Override
            public void run() {
                BmobUser currentUser = BmobUser.getCurrentUser(User.class);
                //逻辑判断是否登录,登陆了进入对应用户界面
                if (currentUser!=null) {
                    String id=currentUser.getObjectId();
                    BmobQuery<User> query=new BmobQuery<>();
                    query.getObject(id, new QueryListener<User>() {
                        @Override
                        public void done(User user, BmobException e) {
                            if(user.getType().equals("student")){
                                startActivity(new Intent(splash.this, studentinterface.class));
                            }
                            else if(user.getType().equals("teacher")){
                                startActivity(new Intent(splash.this,teacherinterface.class));
                            }
                        }
                    });
    
                }
                else {
                    startActivity(new Intent(splash.this, mobloging.class));
               }
    
            }
        };
    }
    

      

  • 相关阅读:
    【小工具】根据定义的白名单字段进行Bean的拷贝
    【Java】Java8的Lambda入门记录
    【Java】浅谈Java IO
    【工具】我的Git学习日志
    【Java】浅谈HashMap
    【Java】Java Queue的简介
    【ZooKeeper】ZooKeeper入门流水记
    【MQTT】Mosquitto的安装与使用流水记
    【数据结构】简单的数据结构图解
    【Java多线程】JDK1.5并发包API杂谈
  • 原文地址:https://www.cnblogs.com/tgthz/p/13088961.html
Copyright © 2020-2023  润新知