2. Contents
• Data types and Methods
• Conditional Statements
• Intents
• Java coding in a sign up activity
3. Data types and Methods
• Data types in android? More like data types in java!
• Simple put, data type specifies the type of data you want to put in your variable
Two types of data types
1. Primitive
2. Non-primitive
5. Non-primitive data types
• Not pre-defined by java (except ‘String’)
• They have attributes and methods associated with them
6. Classes and objects
• Java is an object-oriented programming language.
• Everything in Java is associated with classes and objects, along with its attributes
and methods. For example: in real life, a car is an object. The car has attributes,
such as weight and color, and methods, such as drive and brake.
• A Class is like an object constructor, or a "blueprint" for creating objects.
• Syntax:
<access-modifier> class <class-name> [optional: extends <super-class name>]
[optional: implements <interface name>]
{
….
}
7. Classes and objects
• A class alone is not functional since it is just a blueprint.
• Think of it this way, Just a recipe to make biryani is no good. When you carry out
that recipe and actually cook biryani that is when it is eatable.
• When you make the object its called instantiation of object. The keyword ‘new’ is
used to create an instance of a class in java.
• Syntax: <class-name> <object-name> = new <class-name>()
• E.g. ClassA objectOfA=new ClassA()
• Here ‘ClassA()’ is the constructor of the class
11. Methods
• Methods or functions are simple block of code that perform some task
• It’s just a block of code with a name and can be called anywhere.
• Syntax:
<access-modifiers> <return-type> <function-name> ( <parameters> ){
//function definition
}
E.g. public void exFunction(int value){
//definition
}
18. Intents
• Intents are simply the
messaging objects that enable
activities to communicate
• They can navigate from one
activity to another and even
send data between activities
20. Before moving on…
package com.example.explicitintentdemo;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
21. Explicit Intents
• Explicit intents specify which application will satisfy the intent, by supplying
either the target app's package name or a fully-qualified component class name.
You'll typically use an explicit intent to start a component in your own app,
because you know the class name of the activity or service you want to start. For
example, you might start a new activity within your app in response to a user
action, or start a service to download a file in the background.
28. Implicit Intents
• Implicit intents do not name a specific component, but instead declare a general
action to perform, which allows a component from another app to handle it. For
example, if you want to show the user a location on a map, you can use an
implicit intent to request that another capable app show a specified location on a
map.