Step by step process to create your own Android Application

Here you will learn how to create your android application. If your are looking to make your own android application then follow steps and make your own app.

Step 1: How to create android app
download Android studio from http://developer.android.com/sdk/index.html
After installing the file – open the android studio

Go to file-New ---new project


Step 2
Name of the project and secondly name the company name or domain name or personal name.

Step 3
Select from minimum SDK version and purpose of your application is mobile and tablet or Android TV or Android viewers (smart watches) or Google Glass
Step 4
After selecting any one of these, some code is generated.

Step 5
 Default its generated java class and xml file and you change them also.  

Step 6
 Build your application and some jar files in your project.













Step 7 After code is generated. Java file and xml file will be open
  
Step 8 
activity_man.xml
You can create your first screen just as login screen as shows below  

You can redesign above screen. To design the above just you follow below code or syntax.
Syntax in xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.infasta.logindemo.MainActivity">

<
Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:id="@+id/SignUp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="108dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:onClick="loginPage"/>

<
Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Signup"
android:id="@+id/button2"
android:layout_below="@+id/SignUp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/SignUp"
android:layout_alignEnd="@+id/SignUp"
android:onClick="signupPage"/>
</
RelativeLayout>

Step 9
MainActivity.java


syntax in java file
package com.infasta.logindemo;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.
activity_main);
}
//login button method
public void loginPage(View v){
Intent intent=
new Intent(this,LoginActivity.class);
startActivity(intent);
}
//signup button method
public void signupPage(View v){
Intent intent=
new Intent(this,LoginActivity.class);
startActivity(intent);
}
}

Step 10 
 create new Activity, if you want new screen you can follow screen shot and as well as code or syntax




Step 11 activity_login.xml
To create the login screen you can follow the syntax in xml file  

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"

tools:context="com.infasta.logindemo.LoginActivity">

<
EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="77dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="user name"/>

<
EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:layout_below="@+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/editText"
android:layout_alignEnd="@+id/editText"
android:hint="password"/>

<
Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:onClick="homePage"
android:id="@+id/button"
android:layout_below="@+id/editText2"
android:layout_centerHorizontal="true" />
</
RelativeLayout>


Step 12   LoginActivity.java
To create the login screen you can follow the syntax in java file


package com.infasta.logindemo;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class LoginActivity extends AppCompatActivity {
EditText
nameEdt,passEdt; //user reference variable names
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.
activity_login);
//register the editText id's and type cast to xml id's
nameEdt=(EditText)findViewById(R.id.editText);
passEdt=(EditText)findViewById(R.id.editText2);
}
public void homePage(View v){
//navigation one screen to another screen
//current class and target class name
Intent intent=new Intent(this,LoginActivity.class);
startActivity(intent);
}

}
Step 13
Activity_signup.xml
To create sign up screen in xml file just follow the below syntax  


< ?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.infasta.logindemo.SignUpActivity">

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="New User"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="54dp" />

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Name"
android:id="@+id/textView2"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="50dp" />

<
EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText3"
android:layout_alignBottom="@+id/textView2"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView" />

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Phone"
android:id="@+id/textView3"
android:layout_alignBottom="@+id/editText4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<
EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="@+id/editText4"
android:layout_below="@+id/editText3"
android:layout_alignRight="@+id/editText3"
android:layout_alignEnd="@+id/editText3" />

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Password"
android:id="@+id/textView4"
android:layout_alignBottom="@+id/editText5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<
EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="@+id/editText5"
android:layout_below="@+id/editText4"
android:layout_alignLeft="@+id/editText4"
android:layout_alignStart="@+id/editText4" />

<
Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="signup"
android:id="@+id/button3"
android:layout_below="@+id/textView4"
android:layout_alignRight="@+id/textView"
android:layout_alignEnd="@+id/textView"
android:layout_marginTop="40dp"
android:onClick="signup"/>
</
RelativeLayout>

Step 14      SignupAcitvity.java
To create sign up screen in java file just follow the below syntax.
package com.infasta.logindemo;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class SignUpActivity extends AppCompatActivity {
EditText
nameEdt,passEdt,phoneEdt; //user reference variable names
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.
activity_sign_up);
//register the editText id's and type cast to xml id's
nameEdt=(EditText)findViewById(R.id.editText3);
passEdt=(EditText)findViewById(R.id.editText4);
phoneEdt=(EditText)findViewById(R.id.editText5);
}
//button
public void signup(View v){
//get the values from edit text
String name=nameEdt.getText().toString();
String pass=
passEdt.getText().toString();
String phone=
phoneEdt.getText().toString();
//navigation one screen to another screen
//current class and target class name
Intent intent=new Intent(this,HomeActivity.class);
//put the values from Intent
intent.putExtra("key1",name);//key and value pair
intent.putExtra("key2",pass);
intent.putExtra(
"key3",phone);
startActivity(intent);
}
}
Step 15   Activity_home.xml
passing the values from one to other screen. You can follow the below syntax

in xml.file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.infasta.logindemo.HomeActivity">

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Name:"
android:id="@+id/textView5"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="96dp" />

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView6"
android:layout_alignTop="@+id/textView5"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="password"
android:id="@+id/textView7"
android:layout_below="@+id/textView5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView8"
android:layout_below="@+id/textView5"
android:layout_alignRight="@+id/textView6"
android:layout_alignEnd="@+id/textView6" />

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Phone"
android:id="@+id/textView9"
android:layout_below="@+id/textView7"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<
TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView10"
android:layout_alignTop="@+id/textView9"
android:layout_alignLeft="@+id/textView8"
android:layout_alignStart="@+id/textView8" />

</RelativeLayout>
HomeActivity.java
passing the values from one to other screen. You can follow the below syntax
in java files
package com.infasta.logindemo;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class HomeActivity extends AppCompatActivity {
TextView
name,pass,phone;//user reference variable names
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.
activity_home);
//register the editText id's and type cast to xml id's
name=(TextView)findViewById(R.id.textView6);
pass=(TextView)findViewById(R.id.textView8);
phone=(TextView)findViewById(R.id.textView10);
//get the values from Intent
Intent intent=getIntent();
//Display the values
name.setText(intent.getStringExtra("key1"));//key1=intent key name
pass.setText(intent.getStringExtra("key2"));
phone.setText(intent.getStringExtra("key3"));

}
}
if you follow above steps you can create own app just like sign up and Login App.

Tags: How to Create Android App , Building Your First App,Creating an Android Project by urself, How to build an Android application, Android Development for Beginners

No comments:

Powered by Blogger.