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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:00:19+00:00 2026-05-26T00:00:19+00:00

I got android app based on 2 activities. The Main activity is just a

  • 0

I got android app based on 2 activities. The Main activity is just a input field and a button to get some user information. When the user press the button a barcodescanner (ZXING) will start.

Every thing works perfect. But know i try to check in the onCreate if user information is already known. If its true -> start the barcodescanner. But it looks like the barcodescanner activity starts up twice, because:
pressing back button once: annother barcodescanner wil be active.
pressing back button twice: Main activty will be active.

this is the check inside onCreate:

if(pref.length() == 6){
       startActivityForResult(intent, 0); 

}

and this is the function called when clicking the button:

 public void onClick(View view) {
        switch (view.getId()) {
        case R.id.button1:

            final EditText edit =  (EditText) findViewById(R.id.panelID);   
            if(edit.getText().toString().length() == 6){
                String temp = edit.getText().toString();
                Log.e("click", temp);
                Editor e = this.getPreferences(Context.MODE_PRIVATE).edit();
                e.putString("panelID", temp);
                e.commit();

                startActivityForResult(intent, 0);
            } else {
                Toast.makeText(this, "Ongeldige invoer (6 cijfer id)", Toast.LENGTH_LONG).show();
            }

            break;
        }
    }

What do i do wrong?

  • 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-26T00:00:19+00:00Added an answer on May 26, 2026 at 12:00 am

    Your trouble seems to be more with how you are managing the lifecycle of the activity. If you post your Activity’s onCreate() method’s code, we might be able to see better what you’re trying to accomplish and suggest a solution accordingly.

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

Sidebar

Related Questions

I'm writing my first location based android app, but got confused about some of
I have got some inapp billing in my Android app. When the user clicks
I've got some XML resources in my Android app. Each one has a different
in my Android app I've got two activities, lets say A and B. A
I got the following code inside my templateApp.java: package com.android.templateApp; import android.app.Activity; import android.os.Bundle;
I've got a question: In my Android app there is an activity containing a
Straight Forward: User logs into my iPhone/Android App with Facebook SDK [so i got
I'm a Java developer at heart. Just got Android based phone and curious if
I've got an Android app which has a periodic background Service. I want this
I just got my first Android device, I love it... I also love the

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.