程序小兵 2016-09-11 06:56 采纳率: 0%
浏览 1064

这些代码是什么意思?能修改下把登陆界面取消,直接进入首页界面吗

getWindow().setBackgroundDrawableResource(R.drawable.splash_image);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

    // 判断是否是logout注销,退出
    boolean isLogout = app.userPreferenceHandler.getBoolean(Setting.sp_is_logout, true);
    if (isLogout) {
        // 登录页面
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                gotoLoginActivity();
            }
        }, wait_time);
    } else {
        phone = app.userPreferenceHandler.getString(Setting.sp_user_phone, null);
        password = app.userPreferenceHandler.getString(Setting.sp_user_password, null);
        if (TextUtils.isEmpty(phone) || TextUtils.isEmpty(password)) {
            // 登录页面   delay延时
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    gotoLoginActivity();
                }
            }, wait_time);
        } else {
            // 自动登录
            startTime = System.currentTimeMillis();
            new LoginAsynctask(this, LOGIN, false).execute(phone, password);
        }
    }
}

private void gotoMainActivity() {
    if (!isBack) {
        Intent intent = new Intent(SplashActivity.this, MainActivity.class);
        intent.putExtra(Setting.intent_push_click, getIntent().getIntExtra(Setting.intent_push_click, 0));
        startActivity(intent);
        finish();
    }
}

private void gotoLoginActivity() {
    if (!isBack) {
        Intent intent = new Intent(SplashActivity.this,LoginActivity.class);
        startActivity(intent);
        finish();
    }
}

@Override  //对于Activity 可以单独获取Back键的按下事件
public void onBackPressed() {
    super.onBackPressed();
    isBack = true;
}

@Override  //statusBar状态栏
public int statusBarColor() {
    return Color.TRANSPARENT;
}

@Override   //请求成功
public void requestSuccess(int id, String data) {
    if (id == LOGIN) {
        UserInfo info = ResultJsonHandler.getUserInfo(data);
        info.setPhone(phone);
        app.login(info, password);
        long time = System.currentTimeMillis() - startTime;
        if (time >= wait_time) {
            gotoMainActivity();
        } else {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    gotoMainActivity();
                }
            }, wait_time - time);
        }
    }
}

@Override   //请求失败
public void requestFail(int id, int errorCode, String errorMsg) {
    if (id == LOGIN) {
        ToastUtil.show(this, errorMsg);
        long time = System.currentTimeMillis() - startTime;
        if (time >= wait_time) {
            gotoLoginActivity();
        } else {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    gotoLoginActivity();
                }
            }, wait_time - time);
        }
    }
}

@Override  //请求中断
public void requestBreak(int id) {

}

@Override  //联网失败
public void networkError(int id) {
    if (id == LOGIN) {
        ToastUtil.show(this, R.string.network_error_hint);
        long time = System.currentTimeMillis() - startTime;
        if (time >= wait_time) {
            gotoLoginActivity();
        } else {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    gotoLoginActivity();
                }
            }, wait_time - time);
        }
    }

}
}

  • 写回答

2条回答

  • 祝愿大家都不脱发 2016-09-11 07:01
    关注

    代码有全屏的好像,其他的不知道,还有想进主界面不是只要把

                <category android:name="android.intent.category.LAUNCHER" />
    


    这句话在AndroidManifest.xml中的主界面的地方加上就行了

    评论

报告相同问题?

悬赏问题

  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊