@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.d("estoy_en_main_activity", "Hola!"); /** Obtengo el token que he recibido como extra */ if (getIntent().getStringExtra("token") != null) USER_TOKEN = getIntent().getStringExtra("token"); /** * Compruebo si hay usuarios registrados en el local, y si es asÃ, compruebo si el token ha * expirado */ final UsersDB usersDB = new UsersDB(this); if (usersDB.isEmpty()) { Intent intent = new Intent(contexto, Login.class); startActivity(intent); } else { USER_TOKEN = usersDB.getUsers().getToken(); CheckToken ct = new CheckToken(); ct.execute(USER_TOKEN); String resp = "NO-RESP"; try { resp = ct.get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } if (resp.equals("EXPIRED")) { Intent needLogin = new Intent(contexto, Login.class); startActivity(needLogin); } } welcome = (TextView) findViewById(R.id.welcome); list = (Button) findViewById(R.id.list); tools = (Button) findViewById(R.id.tools); sync = (TextView) findViewById(R.id.flag_sync); play = (Button) findViewById(R.id.playButton); logout = (Button) findViewById(R.id.btn_logout); setTitle("English Quizz"); // getActionBar().setBackgroundDrawable(new ColorDrawable()); checkSynchronized(); play.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(contexto, GameSettings.class); i.putExtra("token", USER_TOKEN); startActivity(i); } }); list.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(contexto, WordList.class); i.putExtra("token", USER_TOKEN); startActivity(i); } }); logout.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { UsersDB uDB = new UsersDB(contexto); uDB.deleteAll(); Intent i = new Intent(contexto, Login.class); startActivity(i); } }); }
@Override protected String getChoiceTitle() { return subtoken.getDefaultTitle(); }