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 7984627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:20:10+00:00 2026-06-04T11:20:10+00:00

I have a strange scenario here. I have this code: // For checking if

  • 0

I have a strange scenario here.

I have this code:

// For checking if the person is logged in.
first_time_check();

setContentView(R.layout.main);

// ...next lines of code

and the first_time_check() function checks if the user is logged in for the first time. If their user_id is not in the SharedPreferences, I redirect them to log in:

public void first_time_check()
{   
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences( ProblemioActivity.this);

    String user_id = prefs.getString( "user_id", null ); // First arg is name and second is if not found.
    String first_time_cookie = prefs.getString( "first_time_cookie" , null );               

    // About setting cookie.  Check for first time cookie
    if ( first_time_cookie == null )
    {
        // This user is a first-time visitor, 1) Create a cookie for them
        first_time_cookie = "1";

        // 2) Set it in the application session.
        prefs.edit().putString("first_time_cookie", first_time_cookie ).commit(); 

        // Make a remote call to the database to increment downloads number
        // AND send me an email that it was a new user.                 
    }        
    else
    {
        // If not first time, get their id.
        // If user_id is empty, make them an account.  
        // If id not empty, call the update login date and be done.         

        if ( user_id == null )
        {
            // User id is null so they must have logged out.                                
            Intent myIntent = new Intent(ProblemioActivity.this, LoginActivity.class);
            ProblemioActivity.this.startActivity(myIntent);
        }
        else
        {               
            // Make a remote call to the database to increment downloads number                                 
        }
    }

return;
}       

So after the code executes the

            Intent myIntent = new Intent(ProblemioActivity.this, LoginActivity.class);
            ProblemioActivity.this.startActivity(myIntent);

it still executes below the original code that calls this functions.

Any idea how that can happen?

Thanks!!

  • 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-06-04T11:20:11+00:00Added an answer on June 4, 2026 at 11:20 am

    This is excerpted from the Dev Guide

    Shutting Down an Activity
    You can shut down an activity by calling its finish() method.
    You can also shut down a separate activity that you previously
    started by calling finishActivity().
    
    Note: In most cases, you should not explicitly finish an activity
    using these methods. As discussed in the following section about the
    activity lifecycle, the Android system manages the life of an
    activity for you, so you do not need to finish your own activities.
    Calling these methods could adversely affect the expected user
    experience and should only be used when you absolutely do not want
    the user to return to this instance of the activity.
    

    Calling finish() on the activity seems appropriate here as you do not want the user to return to this activity.

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

Sidebar

Related Questions

I have this strange scenario. I have a table having multiple rows (each generated
Kind of a strange question, but here is my scenario: I have accidentally added
I have a scenario which is causing strange behavior with WPF data binding and
I have strange scenario in which if I create database using SQL Server 2008
I have the following strange scenario with spring's transaction management: I have method A
I have to accomplish a strange peculiar scenario. Its described as follows: I have
Here's the scenario: I have a multi threaded java web application which is running
I have run into a very strange scenario. There is a .resx file in
I have this strange issue where anytime I open a XAML file that contains
I am in a strange problem. I have an asp.net mvc web page. Scenario

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.