SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Downloaden Sie, um offline zu lesen
First Android App
&
Overview of App structure
1
Sisoft Technologies Pvt Ltd
SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad
Website: www.sisoft.in Email:info@sisoft.in
Phone: +91-9999-283-283
Development requirements
 Java
 Eclipse IDE
 Android ADT Plugin
 Android SDK
Android App Development
2www.sisoft.in
Eclipse IDE + ADT (Android Development Tools)
 Reduces Development and Testing Time
 Makes User Interface-Creation easier
 Makes Application Description Easier
ADT (Android Development Tools)
ADT (Android Developer Tools) is a plugin for Eclipse that provides a
suite of tools that are integrated with the Eclipse IDE
• Android SDK Manager
• AVD Manager.
• Other android features such as creating or updating projects
(application and library) are integrated throughout the Eclipse IDE.
3www.sisoft.in
Eclipse IDE + ADT
The Android SDK provides the API libraries and developer tools
necessary to build, test, and debug apps for Android.
(http://developer.android.com/sdk/index.html)
 Class Library
 BuildTools
dx – Dalvik Cross-Assembler
aapt – Android Asset Packaging Tool
 Other Tools
adb – Android Debug Bridge
ddms – Dalvik Debug Monitor Service
Logcat – View log messages
 Emulator and System Images
 Documentation and Sample Code
4www.sisoft.in
Android SDK Components
Android Apk Generation Process
5
Android Asset Packaging Tool
aapt
A.java A.class .dex
Dalvik
Executable
(Compress
all class file)
XML
&
Res
&
Menifest
file
B.java
N.java
B.class
N.class
java compiler
Dx Tool
.apk
(Android Package)
Java compiler
Java compiler
jjjj
Run on
AVD
Android Emulator
Android Virtual Device(AVD)
6
Sisoft Technologies Pvt Ltd
SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad
Website: www.sisoft.in Email:info@sisoft.in
Phone: +91-9999-283-283
Android Emulator (AVD)
• The Android SDK includes a mobile device emulator --a virtual
mobile device that runs on your computer.
• The emulator lets you prototype, develop, and test Android
applications without using a physical device.
• The Android emulator mimics all of the hardware and
software features of a typical mobile device, except that it can
not receive or place actual phone calls.
• It provides a variety of navigation and control keys, which you
can "press" using your mouse or keyboard to generate events
for your application.
• It also provides a screen in which your application is
displayed, together with any other Android applications
running.
7
www.sisoft.in
Android Emutator (AVD)
Menu
next
Back
power
Volume
Click here
for open
Menu
8
www.sisoft.in
Android Emulator
Click here
for open
setting 9
www.sisoft.in
Android Emulator
• Controlling the Android
Emulator through
keyboard
• Keypad keys only work
when NumLock is
deactivated.
10www.sisoft.in
Create AVD
Step 1
1. Start Eclipse
2. Click AVD icon
to create AVD
AVD Icon for
Create AVD
SDK
Manager
Icon
11
www.sisoft.in
Create AVD step 2
• Click new Button.
12
www.sisoft.in
Create AVD step 3
13
www.sisoft.in
• Enter Details :- 1. Enter
AVD Name
2. Select
Device
4. Select
AVD
camera
5.Enter RAM
& Storage
Size
3. Select
Android
Version
6.Enter
SD card
Size7.Finaly
Click ok
Create AVD step 4
• Select AVD and Start it.
Click Start
Button
Select
SisoftAVD
14
www.sisoft.in
Create AVD step 5
• Now Launch AVD.
Click
here
15
www.sisoft.in
Create AVD step 6
Uploading
16
www.sisoft.in
Create AVD step 7
Active Emulator
Click
here for
unlock
17
www.sisoft.in
First Android App
– Objective: Print Hello Sisoft on main screen
– Create an activity. Which will contain another
screen layout that will have TextView as control
– Content of the TextView may be set by two
methods:
• Using XML layout and view
• By creating view/layout thru program
18www.sisoft.in
First Android Apps
How to create first App on android
Step 1
1. Start Eclipse
3. Select New
2. Click File
1. Enter Android
Application project
19www.sisoft.in
First Android Apps
Step 2
1. Enter App Name
2. Enter Project Name
3. Enter pack Name
4. Select min & max
SDK ver
5. Enter Next button
20www.sisoft.in
First Android Apps
Step 3
21www.sisoft.in
First Android Apps
Step 4
1. Select icon image file
2. Click Next button for
go to next window
22www.sisoft.in
First Android Apps
step 5
1. Select Blank Activity
2. Click Next button for
go to next window
23www.sisoft.in
First Android Apps Step 6
1. Enter java file(Activity)
Name
3. Click finish button
2. Enter xml file(Layout)
Name
24www.sisoft.in
Hello Sisoft.java
first way (By creating view in program)
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public HelloSisoft extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android – by hand");
setContentView(tv);
}
} 25
Set the view “by hand” –
from the program
Inherit
from the
Activity
Class
www.sisoft.in
Second Way(Using XML layout)
/res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
26
Further redirection to
/res/values/strings.xml
www.sisoft.in
/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, HelloAndroid – by
resources!</string>
<string name="app_name">Hello, Android</string>
</resources>
27www.sisoft.in
HelloSisoft.java
28
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
public class HelloAndroid extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Set the layout of the view
as described in the
main.xml layout
www.sisoft.in
www.sisoft.in 29
Directory structure
• When you create app then Eclipse IDE create
Directory Structure
• You can look on the Package Explorer( Usually
on left side)
www.sisoft.in 30
www.sisoft.in 31
src hold the java file
gen hold the R.java file
assets hold the web page
res hold all resources like
xml , image, string, style file
layout folder hold the all
xml layout pages
Manifest file is root directory file
Values folder hold the
string and styles file
R.Java file provide resource
AndroidManifest.Xml File
• Each application must have an AndroidManifest.xml
file (with precisely that name) in its root directory.
• The manifest defines the structure and meta data of
the application and each of its component
• Only the <manifest> and <application> elements are
required, they each must be present and can occur
only once
32www.sisoft.in
Structure of AndroidManifest.xml
www.sisoft.in 33
<manifest>
<Elements for Application properties should come here >
<application>
<Elements for application components should come here >
</application>
</manifest>
• uses-permission – used to specify permissions that are requested for the purpose
of security.
• permission – used to set permissions to provide access control for some specific
component of the application.
• permission-group – does the same as above for a set of components.
• permission-tree – refer one specific name of the component which is the owner or
parent of the set of component.
• instrumentation – enables to know interaction between Android system and
application.
• uses-sdk – specifies the platform compatibility of the application.
• uses-configuration – specifies set of hardware and software requirement of the
application.
• uses-feature – specifies single hardware and software requirement and their
related entity.
• supports-screens, compatible-screens – both these tags deals with screen
configuration mode and size of the screen and etc.
• supports-gl-texture – specifies texture based on which the application is filtered.
www.sisoft.in 34
Manifest.xml: Elements for App Properties
Manifest.xml: Elements for App Components
• These should be enclosed in <application> container.
• activity – has the set of attributes based on user interface.
• activity-alias – specifies target activities.
• service – has the operation provided by any library or API,
running in background that is not visible.
• receiver – that makes to receive message broadcasted by the
same application or by outside entity.
• provider – provides some structure to access application data.
• uses-library – it specifies set of library files need to run the
application.
www.sisoft.in 35
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.sisoft.demo_first“ android:versionCode="1“ android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8“ android:targetSdkVersion="18" />
<application
android:allowBackup="true“ android:icon="@drawable/ic_launcher"
android:label="@string/app_name“ android:theme="@style/AppTheme" >
<activity
android:name="in.sisoft.demo_first.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".Brd1Receiver">
<intent-filter>
<action android:name="in.sisoft.CUSTOM_INTENT" />
</intent-filter>
</receiver>
</application>
www.sisoft.in 36
Sample AndroidManifest.xml
Activity Definition in AndroidManifest.xml
• Add a new activity tag within the application node of the
manifest; the activity tag includes attributes for metadata,
such as the label, icon, required permissions, and themes
used by the Activity
• A period(.) is used as shorthand for the application’s package
name when specifying the Activity’s class name.
• Each Activity node supports intent-filter child tags that define
the Intents that can be used to start the Activity. Each Intent
Filter defines one or more actions and categories that your
Activity supports.
• For an Activity to be available from the application launcher, it
must include an Intent Filter listening for the MAIN action and
the LAUNCHER category
www.sisoft.in
37
Activity Definition in AndroidManifest.xml
<activity
android:name=”.MyActivity”
android:label=”@string/app_name”
android:configChanges=”screenSize|orientation|keyboardHidden”>
<intent-filter >
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
www.sisoft.in
38
Services in Manifest file
• All services must be represented by <service>
elements in the manifest file
(AndroidManifest.xml)
• Required Attributes: android:name
<service
android:name="MyService“
android:icon="@drawable/icon“
android:label="@string/service_name" >
</service>
39www.sisoft.in
Registering Broadcast Receivers in
Application Manifest
• To include a Broadcast Receiver in the
application manifest, add a <receiver> tag
within the application node, specifying the
class name of the Broadcast Receiver to
register
• The receiver node needs to include an intent-
filter tag that specifies the action string being
listened for
40 www.sisoft.in
Registering Broadcast Receivers in
Application Manifest
<receiver
android:name=”.LifeformDetectedReceiver”>
<intent-filter>
<action
android:name=”in.sisoft.NEW_LIFEFORM”/>
</intent-filter>
</receiver>
41 www.sisoft.in
Registering Content Provider in Application Manifest
• Content Providers must be registered in your application
manifest before the Content Resolver can discover them.
• This is done using a provider tag that includes a name
attribute describing the Provider’s class name and an
authorities tag.
• Use the authorities tag to define the base URI of the
Provider’s authority. A Content Provider’s authority is used by
the Content Resolver as an address and used to find the
database you want to interact with
• Each Content Provider authority must be unique, so it’s good
practice to base the URI path on your package name. The
general form for defining a Content Provider’s authority is as
follows: com.<CompanyName>.provider.<ApplicationName>
42 www.sisoft.in
Registering Content Providers in
Application Manifest
<provider
android:name=”.MyContentProvider”
android:authorities=”com.paad.skeletondatabaseprovider
/>
43 www.sisoft.in
Resources
www.sisoft.in
44
Resource Folder Description
Drawables /res/drawables
Images (e.g., png or jpeg files) or XML files which describe a
drawable.
Simple Values /res/values
Used to define strings, colors, dimensions, styles and static arrays
of strings or integers via XML files. By convention each type is
stored in a separate file, e.g., strings are defined in the
res/values/strings.xml file.
Layouts /res/layout
XML files with layout descriptions used to define the user interface
for activities and Fragments.
Styles and
Themes
/res/values Files which define the appearance of your Android application.
Animations /res/animator
Defines animations in XML for the property animation API which
allows to animate arbitrary properties of objects over time.
Raw data /res/raw
Arbitrary files saved in their raw form. You access them via an
InputStream.
Menus /res/menu Defines the properties of entries for a menu.
About R.java file in android application
• There are 2 classes available in each android application with name R.
1. Part of android core system or android SDK, which can be accessed as
android.R We can see this class in R.class file which is available in
android.jar file, which is automatically included in your project by ADT
plugin.
2. Part of our application, which can be accessed as yourpackagename.R.
We can see this class in R.java file which is available in directory gen. This
R.java file is visible, only after successful build of your project.
www.sisoft.in 45
/gen/R.java
package com.example.helloandroid;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int textview=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
46www.sisoft.in
Messaging Command - Toast
• A toast provides simple feedback about an operation
in a small popup.
• Toasts automatically disappear after a timeout.
• If user response to a status message is required,
consider instead using a Notification
• First, instantiate a Toast object with one of the
makeText() methods. This method takes three
parameters: the application Context, the text
message, and the duration for the toast. It returns a
properly initialized Toast object. You can display the
toast notification with show().
www.sisoft.in 47
Toast
• Toast toast = Toast.makeText(context, text, duration);
toast.show();
** Duration : (Toast. LENGTH_LONG, Toast. LENGTH_SHORT)
• A standard toast notification appears near the
bottom of the screen, centered horizontally. You can
change this position with the setGravity(int, int, int)
method. This accepts three parameters: a Gravity
constant, an x-position offset, and a y-position offset.
www.sisoft.in 48
Android.util.Log
• API for sending log output. The order in terms
of verbosity, from least to most is ERROR,
WARN, INFO, DEBUG, VERBOSE.
private static final String TAG = "MyActivity";
Log.d(TAG, "index=" + i);
• You can see the Android log statements via the
LogCat view.
• You can open this view via the Window → Show View
→ Other... → Android → LogCat menu entry.
www.sisoft.in 49
Android.os.Bundle
• Bundle is generally used for passing data
between various Activities of android. It
depends on you what type of values you want
to pass but bundle can hold all types of values
and pass to the new activity
• Bundles are key-value mappings, so in a way
they are like a Hashmap
Bundle b = new Bundle();
B.putString(“myName”, “Sisoft”);
www.sisoft.in 50

Weitere ähnliche Inhalte

Was ist angesagt?

android training_material ravy ramio
android training_material ravy ramioandroid training_material ravy ramio
android training_material ravy ramioslesulvy
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)Google
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_startedAhsanul Karim
 
Eclipse & android setup
Eclipse & android setupEclipse & android setup
Eclipse & android setupChina Bigs
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A NutshellTed Chien
 
[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In ActionHazem Saleh
 
UIViewControllerのコーナーケース
UIViewControllerのコーナーケースUIViewControllerのコーナーケース
UIViewControllerのコーナーケースKatsumi Kishikawa
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basicsAnton Narusberg
 
Titanium Studio [Updated - 18/12/2011]
Titanium Studio [Updated - 18/12/2011]Titanium Studio [Updated - 18/12/2011]
Titanium Studio [Updated - 18/12/2011]Sentinel Solutions Ltd
 
Introduction to android studio 2.0 and data binding library
Introduction to android studio 2.0 and data binding libraryIntroduction to android studio 2.0 and data binding library
Introduction to android studio 2.0 and data binding libraryKaushal Dhruw
 
Android studio
Android studioAndroid studio
Android studioAndri Yabu
 
Android chapter02-setup1-sdk
Android chapter02-setup1-sdkAndroid chapter02-setup1-sdk
Android chapter02-setup1-sdkTran Le Hoan
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with PieOpersys inc.
 
Framework dynamic par Simone Sivetta
Framework dynamic par Simone SivettaFramework dynamic par Simone Sivetta
Framework dynamic par Simone SivettaCocoaHeads France
 
What's new in android 4.4 - Romain Guy & Chet Haase
What's new in android 4.4 - Romain Guy & Chet HaaseWhat's new in android 4.4 - Romain Guy & Chet Haase
What's new in android 4.4 - Romain Guy & Chet HaaseParis Android User Group
 
Android application development
Android application developmentAndroid application development
Android application developmentslidesuren
 

Was ist angesagt? (20)

android training_material ravy ramio
android training_material ravy ramioandroid training_material ravy ramio
android training_material ravy ramio
 
Android Development Tutorial V3
Android Development Tutorial   V3Android Development Tutorial   V3
Android Development Tutorial V3
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)
 
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_started
 
Eclipse & android setup
Eclipse & android setupEclipse & android setup
Eclipse & android setup
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A Nutshell
 
[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action
 
UIViewControllerのコーナーケース
UIViewControllerのコーナーケースUIViewControllerのコーナーケース
UIViewControllerのコーナーケース
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
Titanium Studio [Updated - 18/12/2011]
Titanium Studio [Updated - 18/12/2011]Titanium Studio [Updated - 18/12/2011]
Titanium Studio [Updated - 18/12/2011]
 
Android tutorial1
Android tutorial1Android tutorial1
Android tutorial1
 
Introduction to android studio 2.0 and data binding library
Introduction to android studio 2.0 and data binding libraryIntroduction to android studio 2.0 and data binding library
Introduction to android studio 2.0 and data binding library
 
Android studio
Android studioAndroid studio
Android studio
 
Android chapter02-setup1-sdk
Android chapter02-setup1-sdkAndroid chapter02-setup1-sdk
Android chapter02-setup1-sdk
 
Android development beginners faq
Android development  beginners faqAndroid development  beginners faq
Android development beginners faq
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
 
Framework dynamic par Simone Sivetta
Framework dynamic par Simone SivettaFramework dynamic par Simone Sivetta
Framework dynamic par Simone Sivetta
 
What's new in android 4.4 - Romain Guy & Chet Haase
What's new in android 4.4 - Romain Guy & Chet HaaseWhat's new in android 4.4 - Romain Guy & Chet Haase
What's new in android 4.4 - Romain Guy & Chet Haase
 
Android application development
Android application developmentAndroid application development
Android application development
 

Ähnlich wie First Android App Structure

Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android ApplicationNandini Prabhu
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
Part 2 android application development 101
Part 2 android application development 101Part 2 android application development 101
Part 2 android application development 101Michael Angelo Rivera
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentAhsanul Karim
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2Vivek Bhusal
 
Getting started with android programming
Getting started with android programmingGetting started with android programming
Getting started with android programmingPERKYTORIALS
 
Android installation guide
Android installation guideAndroid installation guide
Android installation guidemagicshui
 
Mobile application development
Mobile application developmentMobile application development
Mobile application developmentumesh patil
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_programEyad Almasri
 
Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)Kavya Barnadhya Hazarika
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introductionaswapnal
 
Android presentation
Android presentationAndroid presentation
Android presentationImam Raza
 
Android OS & SDK - Getting Started
Android OS & SDK - Getting StartedAndroid OS & SDK - Getting Started
Android OS & SDK - Getting StartedHemant Chhapoliya
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMohammad Shaker
 
Android Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start GuideAndroid Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start GuideSergii Zhuk
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Javaamaankhan
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialAbid Khan
 

Ähnlich wie First Android App Structure (20)

Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android Application
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Part 2 android application development 101
Part 2 android application development 101Part 2 android application development 101
Part 2 android application development 101
 
Notes Unit2.pptx
Notes Unit2.pptxNotes Unit2.pptx
Notes Unit2.pptx
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Getting started with android programming
Getting started with android programmingGetting started with android programming
Getting started with android programming
 
Android installation guide
Android installation guideAndroid installation guide
Android installation guide
 
Mobile application development
Mobile application developmentMobile application development
Mobile application development
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Android presentation
Android presentationAndroid presentation
Android presentation
 
Android OS & SDK - Getting Started
Android OS & SDK - Getting StartedAndroid OS & SDK - Getting Started
Android OS & SDK - Getting Started
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 Android
 
Android Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start GuideAndroid Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start Guide
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 

Kürzlich hochgeladen

BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...Nguyen Thanh Tu Collection
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfChristalin Nelson
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPCeline George
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptxmary850239
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEMISSRITIMABIOLOGYEXP
 

Kürzlich hochgeladen (20)

Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdf
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERP
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
CARNAVAL COM MAGIA E EUFORIA _
CARNAVAL COM MAGIA E EUFORIA            _CARNAVAL COM MAGIA E EUFORIA            _
CARNAVAL COM MAGIA E EUFORIA _
 

First Android App Structure

  • 1. First Android App & Overview of App structure 1 Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283
  • 2. Development requirements  Java  Eclipse IDE  Android ADT Plugin  Android SDK Android App Development 2www.sisoft.in
  • 3. Eclipse IDE + ADT (Android Development Tools)  Reduces Development and Testing Time  Makes User Interface-Creation easier  Makes Application Description Easier ADT (Android Development Tools) ADT (Android Developer Tools) is a plugin for Eclipse that provides a suite of tools that are integrated with the Eclipse IDE • Android SDK Manager • AVD Manager. • Other android features such as creating or updating projects (application and library) are integrated throughout the Eclipse IDE. 3www.sisoft.in Eclipse IDE + ADT
  • 4. The Android SDK provides the API libraries and developer tools necessary to build, test, and debug apps for Android. (http://developer.android.com/sdk/index.html)  Class Library  BuildTools dx – Dalvik Cross-Assembler aapt – Android Asset Packaging Tool  Other Tools adb – Android Debug Bridge ddms – Dalvik Debug Monitor Service Logcat – View log messages  Emulator and System Images  Documentation and Sample Code 4www.sisoft.in Android SDK Components
  • 5. Android Apk Generation Process 5 Android Asset Packaging Tool aapt A.java A.class .dex Dalvik Executable (Compress all class file) XML & Res & Menifest file B.java N.java B.class N.class java compiler Dx Tool .apk (Android Package) Java compiler Java compiler jjjj Run on AVD
  • 6. Android Emulator Android Virtual Device(AVD) 6 Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283
  • 7. Android Emulator (AVD) • The Android SDK includes a mobile device emulator --a virtual mobile device that runs on your computer. • The emulator lets you prototype, develop, and test Android applications without using a physical device. • The Android emulator mimics all of the hardware and software features of a typical mobile device, except that it can not receive or place actual phone calls. • It provides a variety of navigation and control keys, which you can "press" using your mouse or keyboard to generate events for your application. • It also provides a screen in which your application is displayed, together with any other Android applications running. 7 www.sisoft.in
  • 8. Android Emutator (AVD) Menu next Back power Volume Click here for open Menu 8 www.sisoft.in
  • 9. Android Emulator Click here for open setting 9 www.sisoft.in
  • 10. Android Emulator • Controlling the Android Emulator through keyboard • Keypad keys only work when NumLock is deactivated. 10www.sisoft.in
  • 11. Create AVD Step 1 1. Start Eclipse 2. Click AVD icon to create AVD AVD Icon for Create AVD SDK Manager Icon 11 www.sisoft.in
  • 12. Create AVD step 2 • Click new Button. 12 www.sisoft.in
  • 13. Create AVD step 3 13 www.sisoft.in • Enter Details :- 1. Enter AVD Name 2. Select Device 4. Select AVD camera 5.Enter RAM & Storage Size 3. Select Android Version 6.Enter SD card Size7.Finaly Click ok
  • 14. Create AVD step 4 • Select AVD and Start it. Click Start Button Select SisoftAVD 14 www.sisoft.in
  • 15. Create AVD step 5 • Now Launch AVD. Click here 15 www.sisoft.in
  • 16. Create AVD step 6 Uploading 16 www.sisoft.in
  • 17. Create AVD step 7 Active Emulator Click here for unlock 17 www.sisoft.in
  • 18. First Android App – Objective: Print Hello Sisoft on main screen – Create an activity. Which will contain another screen layout that will have TextView as control – Content of the TextView may be set by two methods: • Using XML layout and view • By creating view/layout thru program 18www.sisoft.in
  • 19. First Android Apps How to create first App on android Step 1 1. Start Eclipse 3. Select New 2. Click File 1. Enter Android Application project 19www.sisoft.in
  • 20. First Android Apps Step 2 1. Enter App Name 2. Enter Project Name 3. Enter pack Name 4. Select min & max SDK ver 5. Enter Next button 20www.sisoft.in
  • 21. First Android Apps Step 3 21www.sisoft.in
  • 22. First Android Apps Step 4 1. Select icon image file 2. Click Next button for go to next window 22www.sisoft.in
  • 23. First Android Apps step 5 1. Select Blank Activity 2. Click Next button for go to next window 23www.sisoft.in
  • 24. First Android Apps Step 6 1. Enter java file(Activity) Name 3. Click finish button 2. Enter xml file(Layout) Name 24www.sisoft.in
  • 25. Hello Sisoft.java first way (By creating view in program) package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public HelloSisoft extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, Android – by hand"); setContentView(tv); } } 25 Set the view “by hand” – from the program Inherit from the Activity Class www.sisoft.in
  • 26. Second Way(Using XML layout) /res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout> 26 Further redirection to /res/values/strings.xml www.sisoft.in
  • 27. /res/values/strings.xml <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, HelloAndroid – by resources!</string> <string name="app_name">Hello, Android</string> </resources> 27www.sisoft.in
  • 28. HelloSisoft.java 28 package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } Set the layout of the view as described in the main.xml layout www.sisoft.in
  • 30. Directory structure • When you create app then Eclipse IDE create Directory Structure • You can look on the Package Explorer( Usually on left side) www.sisoft.in 30
  • 31. www.sisoft.in 31 src hold the java file gen hold the R.java file assets hold the web page res hold all resources like xml , image, string, style file layout folder hold the all xml layout pages Manifest file is root directory file Values folder hold the string and styles file R.Java file provide resource
  • 32. AndroidManifest.Xml File • Each application must have an AndroidManifest.xml file (with precisely that name) in its root directory. • The manifest defines the structure and meta data of the application and each of its component • Only the <manifest> and <application> elements are required, they each must be present and can occur only once 32www.sisoft.in
  • 33. Structure of AndroidManifest.xml www.sisoft.in 33 <manifest> <Elements for Application properties should come here > <application> <Elements for application components should come here > </application> </manifest>
  • 34. • uses-permission – used to specify permissions that are requested for the purpose of security. • permission – used to set permissions to provide access control for some specific component of the application. • permission-group – does the same as above for a set of components. • permission-tree – refer one specific name of the component which is the owner or parent of the set of component. • instrumentation – enables to know interaction between Android system and application. • uses-sdk – specifies the platform compatibility of the application. • uses-configuration – specifies set of hardware and software requirement of the application. • uses-feature – specifies single hardware and software requirement and their related entity. • supports-screens, compatible-screens – both these tags deals with screen configuration mode and size of the screen and etc. • supports-gl-texture – specifies texture based on which the application is filtered. www.sisoft.in 34 Manifest.xml: Elements for App Properties
  • 35. Manifest.xml: Elements for App Components • These should be enclosed in <application> container. • activity – has the set of attributes based on user interface. • activity-alias – specifies target activities. • service – has the operation provided by any library or API, running in background that is not visible. • receiver – that makes to receive message broadcasted by the same application or by outside entity. • provider – provides some structure to access application data. • uses-library – it specifies set of library files need to run the application. www.sisoft.in 35
  • 36. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="in.sisoft.demo_first“ android:versionCode="1“ android:versionName="1.0" > <uses-sdk android:minSdkVersion="8“ android:targetSdkVersion="18" /> <application android:allowBackup="true“ android:icon="@drawable/ic_launcher" android:label="@string/app_name“ android:theme="@style/AppTheme" > <activity android:name="in.sisoft.demo_first.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name=".Brd1Receiver"> <intent-filter> <action android:name="in.sisoft.CUSTOM_INTENT" /> </intent-filter> </receiver> </application> www.sisoft.in 36 Sample AndroidManifest.xml
  • 37. Activity Definition in AndroidManifest.xml • Add a new activity tag within the application node of the manifest; the activity tag includes attributes for metadata, such as the label, icon, required permissions, and themes used by the Activity • A period(.) is used as shorthand for the application’s package name when specifying the Activity’s class name. • Each Activity node supports intent-filter child tags that define the Intents that can be used to start the Activity. Each Intent Filter defines one or more actions and categories that your Activity supports. • For an Activity to be available from the application launcher, it must include an Intent Filter listening for the MAIN action and the LAUNCHER category www.sisoft.in 37
  • 38. Activity Definition in AndroidManifest.xml <activity android:name=”.MyActivity” android:label=”@string/app_name” android:configChanges=”screenSize|orientation|keyboardHidden”> <intent-filter > <action android:name=”android.intent.action.MAIN” /> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter> </activity> www.sisoft.in 38
  • 39. Services in Manifest file • All services must be represented by <service> elements in the manifest file (AndroidManifest.xml) • Required Attributes: android:name <service android:name="MyService“ android:icon="@drawable/icon“ android:label="@string/service_name" > </service> 39www.sisoft.in
  • 40. Registering Broadcast Receivers in Application Manifest • To include a Broadcast Receiver in the application manifest, add a <receiver> tag within the application node, specifying the class name of the Broadcast Receiver to register • The receiver node needs to include an intent- filter tag that specifies the action string being listened for 40 www.sisoft.in
  • 41. Registering Broadcast Receivers in Application Manifest <receiver android:name=”.LifeformDetectedReceiver”> <intent-filter> <action android:name=”in.sisoft.NEW_LIFEFORM”/> </intent-filter> </receiver> 41 www.sisoft.in
  • 42. Registering Content Provider in Application Manifest • Content Providers must be registered in your application manifest before the Content Resolver can discover them. • This is done using a provider tag that includes a name attribute describing the Provider’s class name and an authorities tag. • Use the authorities tag to define the base URI of the Provider’s authority. A Content Provider’s authority is used by the Content Resolver as an address and used to find the database you want to interact with • Each Content Provider authority must be unique, so it’s good practice to base the URI path on your package name. The general form for defining a Content Provider’s authority is as follows: com.<CompanyName>.provider.<ApplicationName> 42 www.sisoft.in
  • 43. Registering Content Providers in Application Manifest <provider android:name=”.MyContentProvider” android:authorities=”com.paad.skeletondatabaseprovider /> 43 www.sisoft.in
  • 44. Resources www.sisoft.in 44 Resource Folder Description Drawables /res/drawables Images (e.g., png or jpeg files) or XML files which describe a drawable. Simple Values /res/values Used to define strings, colors, dimensions, styles and static arrays of strings or integers via XML files. By convention each type is stored in a separate file, e.g., strings are defined in the res/values/strings.xml file. Layouts /res/layout XML files with layout descriptions used to define the user interface for activities and Fragments. Styles and Themes /res/values Files which define the appearance of your Android application. Animations /res/animator Defines animations in XML for the property animation API which allows to animate arbitrary properties of objects over time. Raw data /res/raw Arbitrary files saved in their raw form. You access them via an InputStream. Menus /res/menu Defines the properties of entries for a menu.
  • 45. About R.java file in android application • There are 2 classes available in each android application with name R. 1. Part of android core system or android SDK, which can be accessed as android.R We can see this class in R.class file which is available in android.jar file, which is automatically included in your project by ADT plugin. 2. Part of our application, which can be accessed as yourpackagename.R. We can see this class in R.java file which is available in directory gen. This R.java file is visible, only after successful build of your project. www.sisoft.in 45
  • 46. /gen/R.java package com.example.helloandroid; public final class R { public static final class attr { } public static final class drawable { public static final int icon=0x7f020000; } public static final class id { public static final int textview=0x7f050000; } public static final class layout { public static final int main=0x7f030000; } public static final class string { public static final int app_name=0x7f040001; public static final int hello=0x7f040000; } } 46www.sisoft.in
  • 47. Messaging Command - Toast • A toast provides simple feedback about an operation in a small popup. • Toasts automatically disappear after a timeout. • If user response to a status message is required, consider instead using a Notification • First, instantiate a Toast object with one of the makeText() methods. This method takes three parameters: the application Context, the text message, and the duration for the toast. It returns a properly initialized Toast object. You can display the toast notification with show(). www.sisoft.in 47
  • 48. Toast • Toast toast = Toast.makeText(context, text, duration); toast.show(); ** Duration : (Toast. LENGTH_LONG, Toast. LENGTH_SHORT) • A standard toast notification appears near the bottom of the screen, centered horizontally. You can change this position with the setGravity(int, int, int) method. This accepts three parameters: a Gravity constant, an x-position offset, and a y-position offset. www.sisoft.in 48
  • 49. Android.util.Log • API for sending log output. The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. private static final String TAG = "MyActivity"; Log.d(TAG, "index=" + i); • You can see the Android log statements via the LogCat view. • You can open this view via the Window → Show View → Other... → Android → LogCat menu entry. www.sisoft.in 49
  • 50. Android.os.Bundle • Bundle is generally used for passing data between various Activities of android. It depends on you what type of values you want to pass but bundle can hold all types of values and pass to the new activity • Bundles are key-value mappings, so in a way they are like a Hashmap Bundle b = new Bundle(); B.putString(“myName”, “Sisoft”); www.sisoft.in 50