zoukankan      html  css  js  c++  java
  • 冲刺(十一)

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

    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));
               }
    
            }
        };
    }
    

      

  • 相关阅读:
    JAVA日报
    JAVA日报
    JAVA日报
    JAVA
    leetcode刷题笔记 222题 完全二叉树的节点个数
    leetcode刷题笔记 221题 最大正方形
    leetcode刷题笔记 220题 存在重复元素 III
    leetcode刷题笔记 219题 存在重复元素 II
    leetcode刷题笔记 218题 天际线问题
    leetcode刷题笔记 216题 组合总和 III
  • 原文地址:https://www.cnblogs.com/dixingchen/p/12794513.html
Copyright © 2011-2022 走看看