Ejemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    dbLogin = new DbLogin(MySplash.this, DbLogin.DB_NAME, null, DbLogin.DB_VERSION);
    db_read = dbLogin.getReadableDatabase();
    db_write = dbLogin.getWritableDatabase();

    String identifier = null;
    TelephonyManager tm = (TelephonyManager) this.getSystemService(this.TELEPHONY_SERVICE);
    if (tm != null) {
      identifier = tm.getDeviceId();
    }
    if (identifier == null || identifier.length() == 0) {
      identifier = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
    }
    Toast.makeText(MySplash.this, "Your IMEI no:" + identifier, Toast.LENGTH_LONG).show();

    System.out.println("IMEI no:" + identifier);
    Log.d("IMEI or Android id:", identifier);

    Cursor cursor = dbLogin.getData(db_read);
    if (cursor.getCount() > 0) {
      Intent intent = new Intent(MySplash.this, MyLogin.class);
      startActivity(intent);
    } else {
      Toast.makeText(MySplash.this, "Login database is empty", Toast.LENGTH_SHORT).show();
      if (identifier != null) {
        new AsynchLogin().execute(identifier);
      } else {
        Toast.makeText(MySplash.this, "Unable to find your IMEI no.", Toast.LENGTH_LONG).show();
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    tv_user_id_login = (TextView) findViewById(R.id.textview_user_login);
    et_user_id_login = (EditText) findViewById(R.id.edittext_user_id);
    button_validate = (Button) findViewById(R.id.button_validate_login);
    button_exit = (Button) findViewById(R.id.button_exit);

    dbLogin2 = new DbLogin(MyLogin.this, DbLogin.DB_NAME, null, DbLogin.DB_VERSION);
    db_read = dbLogin2.getReadableDatabase();
    Cursor cursor = dbLogin2.getUserId(db_read);
    if (cursor.getCount() > 0) {
      Log.d("Login database size", String.valueOf(cursor.getCount()));
      cursor.moveToFirst();
      do {
        user_id = cursor.getInt(cursor.getColumnIndex(DbLogin.USER_ID));
      } while (cursor.moveToNext());
    } else {
      System.out.println("Login database is empty");
    }

    Log.d("Login database user id", user_id.toString());
    // db_read.close();
    // dbLogin2.close();
    /*b_login.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(et_user_id.getText().length() > 0){

            }
            Toast.makeText(MyLogin.this,"hhgjkhk",Toast.LENGTH_SHORT).show();
        }
    });*/
    button_validate.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (et_user_id_login.getText().length() != 0 || et_user_id_login.getText() != null) {
              Integer t = Integer.parseInt(et_user_id_login.getText().toString());
              if (t.equals(user_id)) {
                Intent intent = new Intent(MyLogin.this, ElectricityDeptDaman.class);
                ComponentName cn = intent.getComponent();
                Intent intent1 = IntentCompat.makeRestartActivityTask(cn);
                startActivity(intent1);
                // MyLogin.this.startActivity(intent);
                // startActivity(intent);
              } else {
                Toast.makeText(MyLogin.this, "Wrong User Id !", Toast.LENGTH_SHORT).show();
              }
            } else {
              Toast.makeText(MyLogin.this, "Wrong User Id!", Toast.LENGTH_LONG).show();
            }
          }
        });
    button_exit.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
  }