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

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.