0

I am trying to password protect my application so that the main activity allows the user to enter a password and then submit it by pressing a button.

I have copied the code from another question Password protecting my android app (the simple way)

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;

public class PasswordMenu extends Activity {

    MediaPlayer mpbuttonclick;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        setContentView(R.layout.activity_password_menu);
        mpbuttonclick = MediaPlayer.create(this, R.raw.keypress);
        Button sumbitButton = (Button) findViewById(R.id.button_enterpassword);
        sumbitButton.setOnClickListener(new View.OnClickListener() {        
            public void onClick(View v) {
                EditText passwordEditText = (EditText) findViewById(R.id.text_enterpassword);
                if (passwordEditText.getText().toString().equals("Test")) {
                    startActivity(new Intent("com.berry.intro"));
                    mpbuttonclick.start();
                }
            }
        });
    }

    public void openMenu(View view) {
        Intent intent = new Intent(this , MainMenu.class);
        startActivity(intent);
    } 

    /*@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.password_menu, menu);
        return true;
    }*/

}

However after making some small changes so that it fits my application, I got an error message at the line

mpbuttonclick = MediaPlayer.create(this, R.raw.keypress);

where raw "cannot be resolved or is not a field". Can someone let me know why I am getting this error?

Community
  • 1
  • 1
user3166793
  • 27
  • 2
  • 3
  • 8
  • Try to understand the principals behind the coding design. I did a similar thing for a Custom ListView, but got errors. I sat down and looked through the code, trying to understand it. Just done another Custom ListView, quite happily :) – Swedish Architect Jan 12 '14 at 16:48
  • Did u try to clean and rebuild the project? Did You chcked the tab error in Eclipse? – Frank Jan 12 '14 at 17:28

0 Answers0