Skip to main content

App Bypassing the Login-screen, even though it shouldn"t



Whenever I launch my App, even from a new emulator with now files created it still executes the bit of code, that says if the file has been created do this intent, I don't understand, it shouldn't, I have no way of testing, because I have an iPhone not an Android phone, in theory the code should not be called, only on the second time loading the app.





Thanks!





Code:







Public class LogIn extends Activity implements OnClickListener {

Button send;

EditText user;

EditText pass;

CheckBox staySignedIn;

FileOutputStream Fos;

String a;

String b;

String string = a;

String string2 = b;

String DANNYISREALLLLYYYGAAYYYYYIMNOTBS;



String FILENAME = "userandpass";



@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.login);

send = (Button) findViewById(R.id.bLogIn);

user = (EditText) findViewById(R.id.eTuser);

pass = (EditText) findViewById(R.id.eTpassword);

staySignedIn = (CheckBox) findViewById(R.id.Cbstay);

send.setOnClickListener(this);

File file = getBaseContext().getFileStreamPath(FILENAME);

if (file.exists());

Intent i = new Intent(LogIn.this, ChatService.class);

startActivity(i);}





public void onClick(View v) {

// TODO Auto-generated method stub

switch (v.getId()) {

case R.id.bLogIn:

if (pass.length() == 0)

Toast.makeText(this,

"Try to type in your username and password again!",

Toast.LENGTH_LONG).show();

else if (user.length() == 0)

Toast.makeText(this,

"Try to type in your username and password again!",

Toast.LENGTH_LONG).show();

{

if (staySignedIn.isChecked()) {



String a = user.getText().toString();

String b = pass.getText().toString();

File f = new File(FILENAME);

try {

Fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);

if (Fos != null) {

Fos.write(a.getBytes());

Fos.write(b.getBytes());

}

Fos.close();

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}finally {

String u = user.getText().toString();

String p = pass.getText().toString();

Bundle send = new Bundle();

send.putString("key", u);

send.putString("key1", p);

Intent c = new Intent(LogIn.this, logincheck.class);

c.putExtra("key", u);

c.putExtra("key1", p);

startActivity(c);

Toast.makeText(this, "Were signing you in!", Toast.LENGTH_LONG)

.show();

if (!staySignedIn.isChecked()) {

finish();



break;

}

}

}

}











}

}

}




Comments

  1. You have a semicolon after your test:
    if (file.exists());
    Which would count as the block to run if the conditional is true. Just remove the semicolon and you should be fine.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?