Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private TextView usernameHeader, passwordHeader;
- private EditText username, password;
- private Button loginButton;
- private Handler alertHandler;
- private String userRes, passwdRes;
- SharedPreferences sharedPreferences;
- public static final String MySession = "MySession";
- public static final String nameField = "nameKey";
- public static final String passwordField = "passwordKey";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_login);
- loginButton = (Button) findViewById(R.id.loginButton);
- username = (EditText) findViewById(R.id.username);
- password = (EditText) findViewById(R.id.passwd);
- loginButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- sqlThread.start(); //The loginIntent is called inside the thread using a handler
- }
- });
- }
- public void loginIntent(){
- try{
- sharedPreferences = getSharedPreferences(MySession, Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedPreferences.edit();
- editor.putString(nameField, userRes);
- editor.putString(passwordField, passwdRes);
- editor.apply();
- //editor.commit();
- }catch (Exception ex){
- ex.printStackTrace();
- }
- Intent intent = new Intent(LoginActivity.this, MainActivity.class);
- startActivity(intent);
- }
- SharedPreferences sharedPreferences;
- private String name;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- submitButton = (Button) findViewById(R.id.submitButton);
- mMapView = (MapView) findViewById(mapView);
- map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 34.056295, -117.195800, 16);
- mMapView.setMap(map);
- sharedPreferences = getSharedPreferences(LoginActivity.MySession, Context.MODE_PRIVATE);
- name = (String) sharedPreferences.getString(LoginActivity.nameField,"");
- Toast.makeText(MainActivity.this,name,Toast.LENGTH_LONG).show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement