Hi. I'm trying to create an application to make a login screen launch at boot. This application will *(hopefully)* force users to login using an username and a password before they are able to use the home, back, menu and search buttons. So far, I have done *MOST* of the coding and as far as I can see, the login app works. Here are the issues I am needing help with:
1) this application is letting me BYPASS it by pressing the Home Key
2) this application is NOT redirecting me to the homescreen after using the proper username and password
3) This application is letting me bypass the login by pressing the back key
These are the known issues so far. I need someone to SHOW me what I've done wrong in the programming. Please note that I am using eclipse to program, and this is my first android project.
Someone please help me with this project? thank you.
img.imageResizerActiveClass{cursor:nw-resize !important;outline:1px dashed black !important;} img.imageResizerChangedClass{z-index:300 !important;max-width:none !important;max-height:none !important;} img.imageResizerBoxClass{margin:auto; z-index:99999 !important; position:fixed; top:0; left:0; right:0; bottom:0; border:1px solid white; outline:1px solid black;} img.imageResizerActiveClass{cursor:nw-resize !important;outline:1px dashed black !important;} img.imageResizerChangedClass{z-index:300 !important;max-width:none !important;max-height:none !important;} img.imageResizerBoxClass{margin:auto; z-index:99999 !important; position:fixed; top:0; left:0; right:0; bottom:0; border:1px solid white; outline:1px solid black;} img.imageResizerActiveClass{cursor:nw-resize !important;outline:1px dashed black !important;} img.imageResizerChangedClass{z-index:300 !important;max-width:none !important;max-height:none !important;} img.imageResizerBoxClass{margin:auto; z-index:99999 !important; position:fixed; top:0; left:0; right:0; bottom:0; border:1px solid white; outline:1px solid black;}
1) this application is letting me BYPASS it by pressing the Home Key
2) this application is NOT redirecting me to the homescreen after using the proper username and password
3) This application is letting me bypass the login by pressing the back key
These are the known issues so far. I need someone to SHOW me what I've done wrong in the programming. Please note that I am using eclipse to program, and this is my first android project.
- LoginActivity.java filepackage com.appname.login;
import android.app.*;
import android.app.Activity.*;
import android.os.*;
import android.os.Bundle.*;
import android.view.*;
import android.view.View.*;
import android.widget.*;
import android.widget.Button.*;
import android.widget.EditText.*;
import android.widget.Toast.*;
public class LoginActivity extends Activity implements OnClickListener {
String defaultName, defaultPwd;
String userName, passWord;
EditText username, password;
Button login;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_android);
// UI elements gets bind in form of Java Objects
username = (EditText)findViewById(R.id.username);
password = (EditText)findViewById(R.id.password);
login = (Button)findViewById(R.id.login);
defaultName = "USERNAME";
defaultPwd = "PASSWORD";
// now we have got the handle over the UI widgets
// setting listener on Login Button
// i.e. OnClick Event
login.setOnClickListener(loginListener);
}
private OnClickListener loginListener = new OnClickListener() {
public void onClick(View v) {
//getting inputs from user and performing data operations
if(username.getText().toString().equals(defaultName) &&
password.getText().toString().equals(defaultPwd)){
// responding to the User inputs
Toast.makeText(getApplicationContext(), "Login Accepted", Toast.LENGTH_LONG).show();
}else
Toast.makeText(getApplicationContext(), "Login Not Accepted", Toast.LENGTH_LONG).show();
}
};
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}
-Login.xml (res folder)<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
androidrientation="vertical" >
<!-- Login Title -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/login_title"
android:gravity="center_horizontal"
android:textSize="20dp"
/>
<!-- Login Image -->
<ImageView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center_horizontal"
android:src="@drawable/ic_launcher"
android:layout_weight="1.1"
androidadding="20dp"
/>
<!-- layout for Username -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
androidrientation="horizontal"
android:layout_weight="0.01"
androidadding="10dp">
<TextView
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1.0"
android:text="@string/username"
android:textSize="18dp"
/>
<EditText
android:id="@+id/username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:ems="10"
android:inputType="text" >
<requestFocus />
</EditText>
</LinearLayout>
<!-- layout for Password -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
androidrientation="horizontal"
android:layout_weight="0.01"
androidadding="10dp"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1.0"
android:text="@string/password"
android:textSize="18dp"
/>
<EditText
android:id="@+id/password"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1.0"
android:inputType="textPassword"
/>
</LinearLayout>
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login"
android:layout_margin="10dp"
/>
</LinearLayout>
Someone please help me with this project? thank you.
img.imageResizerActiveClass{cursor:nw-resize !important;outline:1px dashed black !important;} img.imageResizerChangedClass{z-index:300 !important;max-width:none !important;max-height:none !important;} img.imageResizerBoxClass{margin:auto; z-index:99999 !important; position:fixed; top:0; left:0; right:0; bottom:0; border:1px solid white; outline:1px solid black;} img.imageResizerActiveClass{cursor:nw-resize !important;outline:1px dashed black !important;} img.imageResizerChangedClass{z-index:300 !important;max-width:none !important;max-height:none !important;} img.imageResizerBoxClass{margin:auto; z-index:99999 !important; position:fixed; top:0; left:0; right:0; bottom:0; border:1px solid white; outline:1px solid black;} img.imageResizerActiveClass{cursor:nw-resize !important;outline:1px dashed black !important;} img.imageResizerChangedClass{z-index:300 !important;max-width:none !important;max-height:none !important;} img.imageResizerBoxClass{margin:auto; z-index:99999 !important; position:fixed; top:0; left:0; right:0; bottom:0; border:1px solid white; outline:1px solid black;}
rientation="vertical" >
adding="20dp"