标签:layout super 处理 ash private 线程池 back getc intent
SplashActivity
public class SplashActivity extends Activity { private Handler handler = new Handler(){ public void handleMessage(Message msg){ // 如果当前activity已经退出,那么我就不处理handler中的消息 if(isFinishing()) { return; } // 判断进入主页面还是登录页面 toMainOrLogin(); } }; // 判断进入主页面还是登录页面 private void toMainOrLogin() { // new Thread(){ // public void run(){ // // } // }.start(); Model.getInstance().getGlobalThreadPool().execute(new Runnable() { @Override public void run() { // 判断当前账号是否已经登录过 if(EMClient.getInstance().isLoggedInBefore()) {// 登录过 // 获取到当前登录用户的信息 UserInfo account = Model.getInstance().getUserAccountDao().getAccountByHxId(EMClient.getInstance().getCurrentUser()); if(account == null) { // 跳转到登录页面 Intent intent = new Intent(SplashActivity.this, LoginAcitivity.class); startActivity(intent); }else { // 登录成功后的方法 Model.getInstance().loginSuccess(account); // 跳转到主页面 Intent intent = new Intent(SplashActivity.this, MainActivity.class); startActivity(intent); } }else {// 没登录过 // 跳转到登录页面 Intent intent = new Intent(SplashActivity.this, LoginAcitivity.class); startActivity(intent); } // 结束当前页面 finish(); } }); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); // 发送2s钟的延时消息 handler.sendMessageDelayed(Message.obtain(),2000); } @Override protected void onDestroy() { super.onDestroy(); // 销毁消息 handler.removeCallbacksAndMessages(null); } }
Model中创建全局线程池
private ExecutorService executorService = Executors.newCachedThreadPool(); public ExecutorService getGlobalThreadPool() { return executorService; }
标签:layout super 处理 ash private 线程池 back getc intent
原文地址:http://www.cnblogs.com/ganchuanpu/p/6040727.html