Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. public Session(Context cntx) {
  2. // TODO Auto-generated constructor stub
  3. prefs = PreferenceManager.getDefaultSharedPreferences(cntx);
  4. }
  5.  
  6. public void setUserID(int userID) {
  7. prefs.edit().putInt("userID", userID).apply();
  8. }
  9.  
  10. public int getID() {
  11. int userID;
  12.  
  13. return userID = prefs.getInt("userID",0);
  14.  
  15. }
  16.  
  17. StringRequest stringRequest = new StringRequest(Request.Method.POST, server_url, new Response.Listener<String>() {
  18. @Override
  19. public void onResponse(String response) {
  20.  
  21. builder.setTitle("Server Response");
  22. builder.setMessage("Response :"+response);
  23.  
  24. session = new Session(getApplicationContext());
  25. int responseInt = Integer.parseInt(response.trim());
  26. session.setUserID(responseInt);
  27.  
  28. Intent myIntent = new Intent(LoginActivity.this, navActivity.class);
  29. startActivity(myIntent);
  30. finish();
  31.  
  32. @Override
  33. protected void onCreate(Bundle savedInstanceState) {
  34. super.onCreate(savedInstanceState);
  35. setContentView(R.layout.activity_my_jars);
  36. session = new Session(getApplicationContext());
  37. userID = (EditText) findViewById(R.id.userID);
  38. builder = new AlertDialog.Builder(MyJars.this);
  39. userID.setText(session.getID());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement