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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:17:36+00:00 2026-06-16T08:17:36+00:00

I want to make password protected android app, but when in this simple program

  • 0

I want to make password protected android app, but when in this simple program system is not matching two strings.

package com.pokmgr;

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

public class MainPM extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pm_layout);

        final EditText pin = (EditText) findViewById(R.id.pinET); 
        final String pass = pin.getText().toString();
        final String code = "ajaj";
        Button enter = (Button) findViewById(R.id.enterBtn);
        enter.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                if (pass.equals(code)) {
                    Intent in = new Intent(MainPM.this, Menu.class);
                    startActivity(in);
                }
                else {
                    Intent in = new Intent(MainPM.this, Menu2.class);
                    startActivity(in);
                }

            }
        });
    }

    /*@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.pm_layout, menu);
        return true;
    }*/
}

I have made Menu and Menu2 class, but every time Menu2 class is accessed. Even if I enter same pass that is “ajaj” [in this code to test]
i have defined both activities in manifest file.

Can’t understand why pass.eqals(code) is not working

  • 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-16T08:17:37+00:00Added an answer on June 16, 2026 at 8:17 am

    The problem is that you are setting pass to the contents of the EditText when the activity gets created. Instead you have to retrieve the contents of your EditText inside the OnClickListener.

    Like this:

    public void onClick(View v) {
        final String pass = pin.getText().toString();
        if (pass.equals(code)) {
            // do something
        } else {
            // do something different
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a simple password protected app using a text file
I want to make a directory and all subfolders and files password protected so
I want to create App that Make My Device with multi-Users username and password
I am new android app developer i want make app for tablets and phone
i want make a popup window for login/signup. so i'v written this code. but
I have a password-protected website in Flash CS4. I want to make so that
I want to make an app which you make a password and username and
I want to make a request to a SOAP Web Service but I don't
I want to make a simple login page, without register just a username and
I have a project in PHP and I want to make a password check

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.