SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Android Application
Fundamentals
Android concepts
• Activity – visual user interface focused on a single thing a user can do
• Service – no visual interface – they run in the background
• Broadcast receiver – receive and react to broadcast announcements
• Content provider – allow data exchange between applications
• Intent
• Manifest

2
Applications
• Written in Java
• Lunching an application makes it the root of a task (not equal task)
• Each application runs in its own process
• Each process has its own separate VM
• Each application is assigned a unique Linux user ID – by default files
of that application are only visible to that application (can be
explicitly exported)
• Android manages memory by process prioritization and it has a
license to kill 

3
Activities
• Basic component of most applications
• Most applications have several activities that start each other as
needed
• Task is a set of Activities arranged in a stack (example Gmail app)
• Stack is independent
• Each is implemented as a subclass of the base Activity class
• Activities can belong to a process that is killed (what to do then?)

4
Understanding the lifecycle

5
Activity states
• Running state
• Activity is in the foreground
• Full access to resource
• Will not be destroyed

• Paused state
•
•
•
•

Activity is visible but not in the foreground
Retains memory resources
Limited opportunity to perform processing
Not likely to be destroyed

• Stopped state
•
•
•
•

Activity is not visible
Should be prepared to lose memory resources
Limited opportunity to perform processing
Very likely to be destroyed

6
Activities – The View
• Each activity has a default window to draw in (although it may
prompt for dialogs or notifications)
• The content of the window is a view or a group of views (derived
from View or ViewGroup)
• Example of views: buttons, text fields, scroll bars, menu items, check
boxes, etc.
• View(Group) made visible via Activity.setContentView() method.

7
Activity DEMO
• Activity Lifecycle
• Getting Views from the Layout
• Menu handling

8
Option menu

9
Options menu

10
Options menu

11
Activity
• Activities use methods and resources do describe menus and layout
• Menu items normally have at least an id and a title
• Use string resource to avoid literal strings
• Prefer the onOptionItemSelected method over the onClick Method
• All activities must be defined in manifest
• Activities are displayed with startActivity method (with intent)
• Each Activity manages its own menu
• Activity life time is not the same as process life time

12
Views and Layouts
• The role of Views and Layouts
• Using Layouts
• Linear Layout
• Relative Layout
• Handling View event Callback

13
The role of Views and Layouts
• Android UI is composed of Layouts and
Views
• Views are UI components
• ViewGroups are Views that hold othe
Views

• Layouts are specialized ViewGroups
• Describe View positioning
• A Layout is commonly the root of the UI
• Layouts are often layered within one
another

• You can construct your UI using
resource or the code

14
Views are positioned based on its parent
layout

15
Using Layouts
• Linear Layout
Layout_gravity = left/right
Layout_weight = number
Gravity affects content and layout gravity affects controll

• Relative Layout
Relative to other control (based on id) and/or parent

• Grid Layout
•
•
•
•
•
•

RolumCount
RowCount
Layout_row
Layout_column
Layout_rowSpan
Layout_columnSpan
16
Layout DEMO

17
Services
• Does not have a visual interface
• Runs in the background indefinitely
• Examples
• Network Downloads
• Playing Music
• TCP/UDP Server

• You can bind to a an existing service and control its operation

18
Broadcast Receivers
• Receive and react to broadcast announcements
• Extend the class BroadcastReceiver
• Examples of broadcasts:
• Low battery, power connected, shutdown, timezone changed, etc.
• Other applications can initiate broadcasts

19
Content Providers
• Makes some of the application data available to other applications
• It’s the only way to transfer data between applications in Android (no
shared files, shared memory, pipes, etc.)
• Extends the class ContentProvider;
• Other applications use a ContentResolver object to access the data
provided via a ContentProvider

20
Intents
• An intent is an Intent object with a message content.
• Activities, services and broadcast receivers are started by
intents. ContentProviders are started by ContentResolvers

21
Shutting down components
• Activities
• Can terminate itself via finish();
• Can terminate other activities it started via finishActivity();

• Services
• Can terminate via stopSelf(); or Context.stopService();

• Content Providers
• Are only active when responding to ContentResolvers

• Broadcast Receivers
• Are only active when responding to broadcasts

22
Android Manifest
• Its main purpose in life is to declare the components to the system:
<?xml version="1.0" encoding="utf-8"?>
<manifest . . . >
<application . . . >
<activity android:name="com.example.project.FreneticActivity"
android:icon="@drawable/small_pic.png"
android:label="@string/freneticLabel"
... >
</activity>
...
</application>
</manifest>

23
Android Manifest
• Version ID and Version name
• Application settings
• Permissions
• Instrumentation
• Use the XML view

24
ANY QUESTIONS?

25

Weitere ähnliche Inhalte

Ähnlich wie Project a day 2 android application fundamentals

Android Training - Part 2
Android Training - Part 2Android Training - Part 2
Android Training - Part 2
Tbldevelopment
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
MugiiiReee
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
Muhammad Sajid
 
mobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptxmobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptx
NgLQun
 

Ähnlich wie Project a day 2 android application fundamentals (20)

Synapseindia android apps overview
Synapseindia android apps overviewSynapseindia android apps overview
Synapseindia android apps overview
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android Mobile App Development basics PPT
Android Mobile App Development basics PPTAndroid Mobile App Development basics PPT
Android Mobile App Development basics PPT
 
Synapseindia android middleware
Synapseindia android middlewareSynapseindia android middleware
Synapseindia android middleware
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
Android Training - Part 2
Android Training - Part 2Android Training - Part 2
Android Training - Part 2
 
Basics 4
Basics   4Basics   4
Basics 4
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development Tutorial
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android - Android Application Fundamentals
Android - Android Application FundamentalsAndroid - Android Application Fundamentals
Android - Android Application Fundamentals
 
Introduction to android basics
Introduction to android basicsIntroduction to android basics
Introduction to android basics
 
Android Workshop_1
Android Workshop_1Android Workshop_1
Android Workshop_1
 
Android overview
Android overviewAndroid overview
Android overview
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
Android 101
Android 101Android 101
Android 101
 
mobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptxmobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptx
 
Android development
Android developmentAndroid development
Android development
 
Introduction to Android Development and Security
Introduction to Android Development and SecurityIntroduction to Android Development and Security
Introduction to Android Development and Security
 

Mehr von Goran Djonovic (12)

Eca online-seminar-session-1.pptx
Eca online-seminar-session-1.pptxEca online-seminar-session-1.pptx
Eca online-seminar-session-1.pptx
 
Teaching kids programming
Teaching kids programmingTeaching kids programming
Teaching kids programming
 
Project a day 4 all
Project a day 4   allProject a day 4   all
Project a day 4 all
 
Project a day 2 introduction to android studio
Project a day 2   introduction to android studioProject a day 2   introduction to android studio
Project a day 2 introduction to android studio
 
Project a day 1 making a great app
Project a day 1   making a great appProject a day 1   making a great app
Project a day 1 making a great app
 
Project a day 1 introduction to project a
Project a day 1   introduction to project aProject a day 1   introduction to project a
Project a day 1 introduction to project a
 
Project a day 1 introduction to android
Project a day 1   introduction to androidProject a day 1   introduction to android
Project a day 1 introduction to android
 
Project a day 1 desinging android ui
Project a day 1   desinging android uiProject a day 1   desinging android ui
Project a day 1 desinging android ui
 
Project a day 1 career in mobile development
Project a day 1   career in mobile developmentProject a day 1   career in mobile development
Project a day 1 career in mobile development
 
Project a day 3 services
Project a day 3   servicesProject a day 3   services
Project a day 3 services
 
Stc ftn-wp7-intro
Stc ftn-wp7-introStc ftn-wp7-intro
Stc ftn-wp7-intro
 
Flatland
FlatlandFlatland
Flatland
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Project a day 2 android application fundamentals

  • 2. Android concepts • Activity – visual user interface focused on a single thing a user can do • Service – no visual interface – they run in the background • Broadcast receiver – receive and react to broadcast announcements • Content provider – allow data exchange between applications • Intent • Manifest 2
  • 3. Applications • Written in Java • Lunching an application makes it the root of a task (not equal task) • Each application runs in its own process • Each process has its own separate VM • Each application is assigned a unique Linux user ID – by default files of that application are only visible to that application (can be explicitly exported) • Android manages memory by process prioritization and it has a license to kill  3
  • 4. Activities • Basic component of most applications • Most applications have several activities that start each other as needed • Task is a set of Activities arranged in a stack (example Gmail app) • Stack is independent • Each is implemented as a subclass of the base Activity class • Activities can belong to a process that is killed (what to do then?) 4
  • 6. Activity states • Running state • Activity is in the foreground • Full access to resource • Will not be destroyed • Paused state • • • • Activity is visible but not in the foreground Retains memory resources Limited opportunity to perform processing Not likely to be destroyed • Stopped state • • • • Activity is not visible Should be prepared to lose memory resources Limited opportunity to perform processing Very likely to be destroyed 6
  • 7. Activities – The View • Each activity has a default window to draw in (although it may prompt for dialogs or notifications) • The content of the window is a view or a group of views (derived from View or ViewGroup) • Example of views: buttons, text fields, scroll bars, menu items, check boxes, etc. • View(Group) made visible via Activity.setContentView() method. 7
  • 8. Activity DEMO • Activity Lifecycle • Getting Views from the Layout • Menu handling 8
  • 12. Activity • Activities use methods and resources do describe menus and layout • Menu items normally have at least an id and a title • Use string resource to avoid literal strings • Prefer the onOptionItemSelected method over the onClick Method • All activities must be defined in manifest • Activities are displayed with startActivity method (with intent) • Each Activity manages its own menu • Activity life time is not the same as process life time 12
  • 13. Views and Layouts • The role of Views and Layouts • Using Layouts • Linear Layout • Relative Layout • Handling View event Callback 13
  • 14. The role of Views and Layouts • Android UI is composed of Layouts and Views • Views are UI components • ViewGroups are Views that hold othe Views • Layouts are specialized ViewGroups • Describe View positioning • A Layout is commonly the root of the UI • Layouts are often layered within one another • You can construct your UI using resource or the code 14
  • 15. Views are positioned based on its parent layout 15
  • 16. Using Layouts • Linear Layout Layout_gravity = left/right Layout_weight = number Gravity affects content and layout gravity affects controll • Relative Layout Relative to other control (based on id) and/or parent • Grid Layout • • • • • • RolumCount RowCount Layout_row Layout_column Layout_rowSpan Layout_columnSpan 16
  • 18. Services • Does not have a visual interface • Runs in the background indefinitely • Examples • Network Downloads • Playing Music • TCP/UDP Server • You can bind to a an existing service and control its operation 18
  • 19. Broadcast Receivers • Receive and react to broadcast announcements • Extend the class BroadcastReceiver • Examples of broadcasts: • Low battery, power connected, shutdown, timezone changed, etc. • Other applications can initiate broadcasts 19
  • 20. Content Providers • Makes some of the application data available to other applications • It’s the only way to transfer data between applications in Android (no shared files, shared memory, pipes, etc.) • Extends the class ContentProvider; • Other applications use a ContentResolver object to access the data provided via a ContentProvider 20
  • 21. Intents • An intent is an Intent object with a message content. • Activities, services and broadcast receivers are started by intents. ContentProviders are started by ContentResolvers 21
  • 22. Shutting down components • Activities • Can terminate itself via finish(); • Can terminate other activities it started via finishActivity(); • Services • Can terminate via stopSelf(); or Context.stopService(); • Content Providers • Are only active when responding to ContentResolvers • Broadcast Receivers • Are only active when responding to broadcasts 22
  • 23. Android Manifest • Its main purpose in life is to declare the components to the system: <?xml version="1.0" encoding="utf-8"?> <manifest . . . > <application . . . > <activity android:name="com.example.project.FreneticActivity" android:icon="@drawable/small_pic.png" android:label="@string/freneticLabel" ... > </activity> ... </application> </manifest> 23
  • 24. Android Manifest • Version ID and Version name • Application settings • Permissions • Instrumentation • Use the XML view 24