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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:46:12+00:00 2026-06-03T23:46:12+00:00

public class LockAppActivity extends Activity{ EditText pass1, pass2; Button back, next; SharedPreferences prefs; public

  • 0
public class LockAppActivity extends Activity{

    EditText pass1, pass2;
    Button back, next;
    SharedPreferences prefs;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.lockapp);

        pass1 = (EditText) findViewById(R.id.edit1);
        pass2 = (EditText) findViewById(R.id.edit2);

        back = (Button) findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {    
            public void onClick(View v1) {
                Intent setIntent = new Intent(Intent.ACTION_MAIN);
                setIntent.addCategory(Intent.CATEGORY_HOME);
                setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(setIntent); 
            }
        });

        next = (Button) findViewById(R.id.next);
        next.setOnClickListener(new View.OnClickListener() {
            String password1 = "";
            String password2 = "";

            public void onClick(View v){

                password1 = pass1.getText().toString();
                password2 = pass2.getText().toString();             

                if (!password1.equals("")){

                    if (password1.length() >= 15){
                        Pattern pattern = Pattern.compile("[[0-9]&&[a-z]&&[A-Z]]");
                        Matcher matcher = pattern.matcher(password1);   

                        if(matcher.matches()){                      

                            if (password1.equals(password2)){
                                //SavePreferences("Password", password1);
                                Intent intent = new Intent(LockAppActivity.this, PhoneNumActivity.class);
                                startActivity(intent);
                            }
                            else{
                                pass1.setText("");
                                pass2.setText("");
                                Toast.makeText(LockAppActivity.this,"Not equal",Toast.LENGTH_LONG).show();
                            }
                        }
                        else{
                            pass1.setText("");
                            pass2.setText("");
                            Toast.makeText(LockAppActivity.this,"Not matched",Toast.LENGTH_LONG).show();
                        }
                    }
                    else{
                        pass1.setText("");
                        pass2.setText("");
                        Toast.makeText(LockAppActivity.this,"Length",Toast.LENGTH_LONG).show();
                    }                       
                }
                else{
                    pass1.setText("");
                    pass2.setText("");
                    Toast.makeText(LockAppActivity.this,"Nothing",Toast.LENGTH_LONG).show();
                }
            }
        });
    }

    private void SavePreferences(String key, String value){
        SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.commit();
    }
}

I faced problem when I entered a valid password but it pops out a toast stated “Not matched” and how I am going to save this password in the apps and when a newer password entered it will update and overwrite the old password

  • 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-03T23:46:14+00:00Added an answer on June 3, 2026 at 11:46 pm

    In the Java regex flavor, && is a set intersection operator. It’s used only inside character classes. Your regex:

    [[0-9]&&[a-z]&&[A-Z]]
    

    …tries to match exactly one character, which must be a member of all three of the sets [0-9], [A-Z], and [a-z]. Obviously, there is no such character. The most common technique for validating passwords with a regex is to use a separate lookahead to match each of the required character types, then do a “for real” match to validate the length and overall composition. In your case it might look like this:

    ^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])[0-9A-Za-z]{15,}$
    

    You’re using the matches() method to apply the regex, so you don’t really have to use the start and end anchors (^ and $), but it doesn’t hurt, and it communicates your intent more clearly to anyone who has to read your code later on.

    Note that I’m only correcting your regex to meets your stated criteria, not commenting on the criteria themselves. And if there are any errors in the Android-specific parts of the code, I wouldn’t know.

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

Sidebar

Related Questions

public class Browser1Activity extends Activity { TextView url; WebView ourBrow; @Override protected void onCreate(Bundle
public class Offer_Popup extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.offer_popup); //newly
public class SettingsActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*
public class master extends Activity { ProgressDialog progressDialog; EditText tahmini_kelime; EditText girilen_sayi ; EditText
public class Test extends Thread{ public void hello(String s){ System.out.println(s); } public void run(){
public class IdAsync extends AsyncTask<String, Void, Void> { AlertDialog alertDialog = new AlertDialog.Builder(MainClass.this).create(); protected
public class HomeActivity extends Activity{ // public ArrayList<User> users1 = new ArrayList<User>(); @Override public
public class Boards : TabActivity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Tab);
public class upload extends Activity { private static final int CAMERA_REQUEST = 1888; private
public class ReportView extends JFrame { Connection con=null; void showReport() throws SQLException, ClassNotFoundException, JRException

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.