+ All Categories
Home > Mobile > Android Training Session 1

Android Training Session 1

Date post: 22-Jan-2018
Category:
Upload: shanmugapriya-d
View: 238 times
Download: 0 times
Share this document with a friend
26
Android Application Fundamentals Basic Java Programming Language Basic Knowledge about XML
Transcript
Page 1: Android Training Session 1

Android Application

Fundamentals

• Basic Java Programming Language

• Basic Knowledge about XML

Page 2: Android Training Session 1

Example

Page 3: Android Training Session 1
Page 4: Android Training Session 1

App Components

• Activities

• Services

• Content Providers

• Broadcast Receivers

• Intents and Intents Filters

Page 5: Android Training Session 1

Activities & Services

Page 6: Android Training Session 1

Broadcast Receivers

& Content Providers

Page 7: Android Training Session 1

Activities Lifecycle

Page 8: Android Training Session 1
Page 9: Android Training Session 1

Intents and Intent Filters

• An Intent is a messaging object you can use to

request an action from another app component.

• Intent Types: 1. Explicit Intent 2. Implicit Intent

1. Explicit Intent: specify the component to start by

name (the fully-qualified 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,

start a new activity in response to a user action or

start a service to download a file in the background.

Page 10: Android Training Session 1

2. 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.

Intent Filters:

<intent-filter>

<action android:name="android.intent.action.SEND"/>

<category android:name="android.intent.category.DEFAULT"/>

<data android:mimeType="text/plain"/>

</intent-filter>

Ex:

<data android:mimeType="application/vnd.google.panorama360+jpg"/>

<data android:mimeType="image/*"/>

<data android:mimeType="video/*"/>

Page 11: Android Training Session 1

Application Permission

• Requests a permission that the application must be

granted in order for it to operate correctly. Permissions

are granted by the user when the application is installed,

not while it's running

1. android.permission.CALL_EMERGENCY_NUMBERS

2. android.permission.READ_OWNER_DATA

3. android.permission.SET_WALLPAPER

4. android.permission.DEVICE_POWER

5. android.hardware.bluetooth

Page 12: Android Training Session 1

Views, Layouts and UI

Components• Provides classes that expose basic user interface classes

that handle screen layout and interaction with the user

• Layouts:

Page 13: Android Training Session 1

Linear layout

Page 14: Android Training Session 1

Relative layout

Page 15: Android Training Session 1

Frame layout

Page 16: Android Training Session 1

UI Components• Input Controls

Page 17: Android Training Session 1

Menu & Action bar

Android Version before 3.0

Page 18: Android Training Session 1

List view and Grid View

• Android List View is a view which groups several items and display them in vertical scrollable list. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database.

• An adapter actually bridges between UI components and the data source that fill data into UI Component. Adapter can be used to supply the data to like spinner, list view, grid view etc.

• The List View and Grid View are subclasses of Adapter View and they can be populated by binding them to an Adapter, which retrieves data from an external source and creates a View that represents each data entry. Android provides several subclasses of Adapter that are useful for retrieving different kinds of data and building views for an Adapter View

Page 19: Android Training Session 1

Example:

String[] countryArray = {"India", "Pakistan", "USA",

"UK"};

ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.ListView,

StringArray);

ListView listView = (ListView)

findViewById(R.id.listview);

listView.setAdapter(adapter);

Page 20: Android Training Session 1

Grid View

• Android GridView shows items in two-dimensional scrolling

grid (rows & columns) and the grid items are not

necessarily predetermined but they automatically inserted

to the layout using a ListAdapter

• An adapter actually bridges between UI components and

the data source that fill data into UI Component. Adapter

can be used to supply the data to like spinner, list view,

grid view etc.

• The ListView and GridView are subclasses of AdapterView

and they can be populated by binding them to an Adapter,

which retrieves data from an external source and creates a

View that represents each data entry.

Page 21: Android Training Session 1

public Integer[] mThumbIds = {

R.drawable.sample_2, R.drawable.sample_3,

R.drawable.sample_4, R.drawable.sample_5,

R.drawable.sample_6, R.drawable.sample_7,

R.drawable.sample_0, R.drawable.sample_1,

R.drawable.sample_2, R.drawable.sample_3,

R.drawable.sample_4, R.drawable.sample_5,

R.drawable.sample_6, R.drawable.sample_7,

R.drawable.sample_0, R.drawable.sample_1,

R.drawable.sample_2, R.drawable.sample_3,

R.drawable.sample_4, R.drawable.sample_5,

R.drawable.sample_6, R.drawable.sample_7

};

public View getView(int position, View convertView, ViewGroup parent)

{

ImageView imageView;

if (convertView == null) {

imageView = new ImageView(mContext);

imageView.setLayoutParams(new

GridView.LayoutParams(85, 85));

imageView.setScaleType(ImageView.ScaleType.CENT

ER_CROP);

imageView.setPadding(8, 8, 8, 8);

} else { imageView = (ImageView) convertView; }

imageView.setImageResource(mThumbIds[position]);

return imageView;

}

Page 22: Android Training Session 1

Tab layout & Swiper Views• TabLayout provides a horizontal layout to display tabs

Page 23: Android Training Session 1

Swipe views

• Efficient navigation is one of the cornerstones of a well-

designed app.

Page 24: Android Training Session 1

Example Code:

Page 25: Android Training Session 1

Adding Styles and

Themes• A style is a collection of properties that specify the look and

format for a view or window. A style can specify properties

such as height, padding, font color, font size, background

color, and much more. A style is defined in an XML resource

that is separate from the XML that specifies the layout.

Ex:

<TextView

style="@style/CodeFont"

android:text="@string/hello" />

Page 26: Android Training Session 1

END


Recommended