2 lyb0924 lyb0924 于 2016.09.11 14:56 提问

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

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个回答

wang_qian_kun
wang_qian_kun   2016.09.11 15:01

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

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


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

wang_qian_kun
wang_qian_kun   2016.09.11 15:05

上边的代码不全,我也不知道怎么了,然后你只要去你的登陆界面里找,然后剪切到你想第一看到的界面就可以了

Csdn user default icon
上传中...
上传图片
插入图片