Upload
cresco
View
83
Download
1
Tags:
Embed Size (px)
DESCRIPTION
10 Days Android Workshop at L J Institute of engineering and technology delivered by Cresco Solution visit: http://www.crescosolution.com/android-workshop-at-l-j-institute-of-engineering-and-technology-ahmedabad/
Citation preview
• Each application runs it’s own process
• Each process has its own separate virtual machine
• Each application is assigned a unique linux user -ID
Application Fundamentals
www.crescosolution.com
Application Fundamentals Types
www.crescosolution.com
Activity
Intent
Android Manifest
Content Provider
Service
Broadcast Receiver
Activity
www.crescosolution.com
Basic component of most applications
Most applications have more than one activities that all start each other as needed
Each activity implements as a subclass of base Activity class.
Each activity is default window
The content of window is view or group of views
Example of views : text , buttons , scroll bars ,menu items etc…
Activity represents presentation layer in android UI.
Intents
www.crescosolution.com
An Intent is exactly what it describes. It's an "intention" to do an action.
An Intent is a messaging object you can use to request an action from anotherapp component.
An Intent is basically a message to say you did or want something to happen.
Although intents facilitate communication between components in several ways.
Types of Intents
www.crescosolution.com
•Specify the component to start by name 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
Explicit 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
Implicit intents
Android Manifest
www.crescosolution.com
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.helloworld"android:versionCode="1" android:versionName="1.0" >
<uses-sdkandroid:minSdkVersion="8"android:targetSdkVersion="15" />
<application android:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" ><activity
android:name=".MainActivity"android:label="@string/title_activity_main" ><intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /></intent-filter>
</activity></application>
</manifest>
Elements of Android Manifest File
www.crescosolution.com
•root element of the AndroidManifest.xml file
•It includes the namespace declaration
•It has package attribute that describes the package name of the activity class<manifest>
•contains several sub elements
•The commonly used attributes are of this element are icon, label, theme etc.<application>
•Each activity must be defined
•android:label represents a label for the activity, often displayed on the screen
•android:name represents a name for the activity class. It is required attribute<activity>
•describes the type of intent to which activity, service or broadcast receiver<intent-filter>
•It adds an action for the intent-filter
•intent-filter must have one or more action elements<action>
•It adds an category name to an intent-filter<category>
Content Providers
www.crescosolution.com
Supplies data from one application to others on request
Such requests are handled by the methods of the ContentResolver class
A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network
Service
www.crescosolution.com
❏ Does not have visual interface❏ Runs in background indefinitely❏ Examples:
Playing Music
❏ You can bind to a an existing service and control its operation
❏ Content provider and intents are short lived but services are always running
❏ Suppose even you exit from app ,the background process running.
Broadcast Receiver
www.crescosolution.com
Receive and react to
broadcast announcements
Extend the class BroadcastReceiver
Examples:
•Low battery, power connected, shutdown, time zone changed, etc.
A broadcast receiver is an Android component which allows you to register for system or application events.