Advertisement
Guest User

Untitled

a guest
Jan 20th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. package com.iserv.iserv_app;
  2.  
  3. import java.util.concurrent.atomic.AtomicBoolean;
  4.  
  5. import android.app.Activity;
  6. import android.content.Intent;
  7. import android.content.SharedPreferences;
  8. import android.content.SharedPreferences.Editor;
  9. import android.os.Bundle;
  10. import android.view.View;
  11. import android.widget.Button;
  12. import android.widget.EditText;
  13.  
  14. public class Login_main extends Activity{
  15.  
  16. public static AtomicBoolean ergebnis = new AtomicBoolean(false);
  17. public Intent newActivity0 = new Intent(Login_main.this,MainActivity.class);
  18. public EditText user;
  19. public EditText pass;
  20. public SharedPreferences pref;
  21. public Editor editor;
  22.  
  23. protected void onCreate(Bundle savedInstanceState) {
  24. super.onCreate(savedInstanceState);
  25. setContentView(R.layout.login_main);
  26.  
  27. pref = getApplicationContext().getSharedPreferences("IservApp", 0);
  28.  
  29. if(pref.contains("logged")){
  30. if(pref.getBoolean("logged", false)){
  31. startActivity(newActivity0);
  32. }
  33. }
  34. user = (EditText) findViewById(R.id.editText1);
  35. pass = (EditText) findViewById(R.id.editText2);
  36.  
  37. Button backbutton = (Button) findViewById(R.id.button1);
  38. backbutton.setOnClickListener(login);
  39.  
  40.  
  41. }
  42.  
  43. View.OnClickListener login = new View.OnClickListener() {
  44. public void onClick(View v) {
  45. String userstring = user.getText().toString();
  46. String passstring = pass.getText().toString();
  47.  
  48. System.out.println("Verbindung wird aufgerufen mit " + userstring + " und " + passstring);
  49.  
  50. ftp_login t = new ftp_login(userstring, passstring);
  51. t.start();
  52. try {
  53. t.join();
  54. } catch (InterruptedException e) {
  55. // TODO Auto-generated catch block
  56. e.printStackTrace();
  57. }
  58.  
  59. if(ergebnis.get()){
  60. editor = pref.edit();
  61. editor.putBoolean("logged", true);
  62. editor.commit();
  63. startActivity(newActivity0);
  64. }
  65. }
  66. };
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement