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

  • Home
  • SEARCH
  • 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 5967341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:55:48+00:00 2026-05-22T19:55:48+00:00

I have an Android app which I use to register users on my web

  • 0

I have an Android app which I use to register users on my web site. My first task is to register a user if my shared preferences file shows there is no registered user information.

If my app has a registered user, I provide the following code to simply and automatically switch to a "homepage" activity:

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.signin);
        
        if( USERPREFERENCES.getString(USERPREFERENCES_USERMAIL, "")  == null && USERPREFERENCES.getString(USERPREFERENCES_USERID, "") == null && USERPREFERENCES.getString(USERPREFERENCES_USERNAME, "") == null){
            //setContentView(R.layout.signin);
            Toast.makeText(SignIn.this, "testing...", Toast.LENGTH_LONG).show();
        }else{
            Intent intent   =   new Intent(SignIn.this, Confirmed.class);
            startActivity(intent);
        }
... other code

So, from my default activity, signin.java, the app will either switch to the Confirmed activity or stay on and display the signin activity.

My problem is, when the system works and I get switched to the the Confirmed activity, I provide a logout onclick listener which is below:

 signout.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                //USERPREFERENCES.cl
                Toast.makeText(Confirmed.this, "signout responding!", Toast.LENGTH_LONG).show();
                USERPREFERENCES.edit().clear().commit();
            }
        });

It responds and clears all my shared preferences variables. But, when I use my menu to manually switch to the sign-in activity, I still get switched back to the Confirmed activity.

This happens even though I can confirm the variables are empty.

  • 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-22T19:55:49+00:00Added an answer on May 22, 2026 at 7:55 pm

    This hardly ever will be true:

    USERPREFERENCES.getString(USERPREFERENCES_USERMAIL, "")  == null
    

    What if you use this instead?

    if( USERPREFERENCES.getString(USERPREFERENCES_USERMAIL, null)  == null && USERPREFERENCES.getString(USERPREFERENCES_USERID, null) == null && USERPREFERENCES.getString(USERPREFERENCES_USERNAME, null) == null){
        //setContentView(R.layout.signin); TRY TO AVOID DOING THIS THING!!!!!
        Toast.makeText(SignIn.this, "testing...", Toast.LENGTH_LONG).show();
    }else...
    

    Also, as a recommendation… instead of being switching between activities… what if you create just a Signing.java activity and put a ViewFlipper in its layout. That way your app will be not only faster but also easier to maintain.

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

Sidebar

Related Questions

I have written an android app which listens to the phone signal strength using
I'm starting an Android app which will have multiple Activities. It will be using
I have an Android application which handles a particular type of file. It registers
I have developed some reusable android component which is basically a class . This
I've written an Android app which various abstract classes that perform useful functions. These
I have an Android app with a ListActivity in the main view. The list
In my Android app, I have a main activity that serves as an entry
In my Android app I use a TabWidget without any special customization. I'd like
Hello I have a bunch of text on my file which i display. I
I am developing an app for android mobiles that communicates with a json/rest web

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.