Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5840215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:42:32+00:00 2026-05-22T11:42:32+00:00

I would like to make sure that when user log in it will stay

  • 0

I would like to make sure that when user log in it will stay in session no matter what happens (crashed, shut down/power down/reboot, leaving the app) at same time the user info data will be sending with all the activities in the app to the webserver.

for example at the start up of the app, user login ‘9999’ it goes to the main activity that have 5 diff. activities. user 9999 will send one activity (i.e. gps location) it will send that info to the webserver as user 9999 gps 123.234 123.123.

I want to ensure the users stays in session and also send its users data with the “activity” data sent.
I read this link

What is the most appropriate way to store user settings in Android application

I was still unable to put it together.

At the same time in the same main screen it has a logout. User needs manager approval to logout by inputting the code(i.e. 1234) to completely logout and for new user to input their id number. I want to know how to put the hardcode ‘1234’ within the activity.

this code is my main screen after login to give you the idea

 MainActivity.java

 import android.app.ListActivity;
 import android.content.Intent; import
 android.os.Bundle; import
 android.view.View; import
 android.widget.ArrayAdapter; import
 android.widget.ListView; import
 android.widget.TextView;

 public class Customer extends ListActivity {TextView selection;
     CustomerListItem[] items ={
          new CustomerListItem("Start Trip",StartTripActivity.class), 
         new CustomerListItem("Clock in",ClockinActivity.class), 
         new CustomerListItem("Customer Svc",CustomerSvcActivity.class), 
         new CustomerListItem("IndependentInspection",InspectionActivity.class), 
         new CustomerListItem("Pick Up", PickUpActivity.class), 
         new CustomerListItem("Log Out", LogoutActivity.class)};    

private TextView resultsTxt;

     @Override
     public void onCreate(Bundle icicle)
     {
         super.onCreate(icicle);
         setContentView(R.layout.main);
         setListAdapter(new ArrayAdapter<CustomerListItem>(
                 this, android.R.layout.simple_list_item_1,
 items));
         selection = (TextView) findViewById(R.id.selection);
     }

     @Override
     protected void onListItemClick(ListView l, View v,
 int position, long id)
     {
         super.onListItemClick(l, v, position, id);
         final Intent intent = new Intent(this,
 items[position].getActivity());
         startActivityForResult(intent, position);
     }

     @Override
     protected void onActivityResult(int requestCode, int
 resultCode, Intent intent)
     {
         super.onActivityResult(requestCode,
 resultCode, intent);
         if (resultCode == RESULT_OK)
         {
             // Perform different actions based on from which activity is
             // the application returning:
             switch (requestCode)
             {
                case 0:
            // TODO: handle the return of the StartTripActivity
            break;
        case 1:
            // TODO: handle the return of the ClockinActivity
            break;
        case 2:
            // TODO: handle the return of the CustomerSvcActivity
        case 3:
            // TODO: handle the return of the InspectionActivity
            break;
        case 4:
            // TODO: handle the return of the PickUpActivity
            break;
        case 5:
            // TODO: handle the return of the LogoutActivity
            break;
        default:
            break;
             }
         }
         else if (resultCode == RESULT_CANCELED)
         {
             resultsTxt.setText("Canceled");
         }
     } }

UPDATE:

Login.java

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


public class Login extends Activity {
    private EditText etUsername;
    private Button btnLogin;
    private Button btnCancel;
    private TextView lblResult;
    /** Called when the activity is first created. */
    //@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);

        etUsername = (EditText)findViewById(R.id.username);
        btnLogin = (Button)findViewById(R.id.login_button);
        btnCancel = (Button)findViewById(R.id.cancel_button);
        lblResult = (TextView)findViewById(R.id.result);

        btnLogin.setOnClickListener(new OnClickListener() {
            //@Override
            public void onClick(View v) {
            // Check Login
            String username = etUsername.getText().toString();

            if(username.equals("guest")){
                lblResult.setText("Login successful.");




                Intent i = new Intent(getApplicationContext(), Customer.class);
                startActivity(i);

            } else {
                 lblResult.setText("Login failed. Username doesn't match.");
             }
            }
            });


            btnCancel.setOnClickListener(new OnClickListener() {
            //@Override
            public void onClick(View v) {
               // Close the application
            finish();
                }
            });
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:42:33+00:00Added an answer on May 22, 2026 at 11:42 am

    The link you included shows the way to store the user’s ID – you can use SharedPreferences or you can store it in the database.

    You can store the “approval code” anywhere. If you want to hard-code it, you may want to put it in a “static” helper class in a public static final String variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to make sure that an applescript can be converted to bash.
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to make sure that everything I know about UTF-8 is correct.
I would like to make sure my classes are robust - even if they
I would like to make sure if a textbox has any content at all,
In my stored procedure, I would like to check to make sure what I
I would like to make my app freeware, but if a user is willing
I'm trying to make a ASP.NET (C#) poll that will ask a user a
I'm working with Stripe, and I want to make sure that when a user
I would like to make a simple user login/registration system using PHP and mysql.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.