Mobile_ICP8 - Ggr9d/Web-and-Mobile-Programming GitHub Wiki

Web and Mobile programming

In Class Programming 8

As part of this ICP, we have to Understand the starter code given for text view, button view, and make a simple login application with the following requirements.

a. The main activity should look as below (make suitable changes for the login app!).

b. Create the 'Login' button on the login screen.

c. When clicked on the 'Login' button, the screen should navigate to the welcome screen if the login credentials are valid. Otherwise, the app should display an appropriate message to the user.

d. Create the 'LOGOUT' button on the welcome screen. When clicked on the 'LOGOUT' button, the screen should navigate to the login screen.

Installations:

As part of this task, we have installed the Java Development Kit(JDK) and Android Studio.

Task implementation:

1. AndroidManifest.xml: This file contains the information about the metadata of Android application such as package name, main activity, and home activity.

2. MainActivity.java: This file contains the login code. Here we are calling the myLogin() function and here we are validating the cases where the username and password not empty. We have hardcoded the login credentials and if the username and the password provided is correct the login is successful. Displays the “Invalid login credentials” when user enters the incorrect details.

3. HomeActivity.java: When we press the logout button it calls to the myLogout() function and redirects to the main login page.

4. Activity_main code and layout: This shows the layout of the main page of the android application and the related xml code.

5. Activity_home code and layout: This shows the layout of the home page of the android application and the related xml code.

Output:

Here, we have used emulator to view the output.

  1. Below is the initial screen displayed when android app is loaded.

  1. Entering the login details

  1. Home screen after logging in

  1. After hitting the logout button, we will be redirected to the main login page.

  1. When we enter incorrect username and password,”Inavalid login credentials” will be displayed.