SlideShare a Scribd company logo
Android Application Tutorial
                                     How to add a splash screen with a timer


  Instructed on: 02-Mar-2012 | Tutorial: #06




                                                                    6 
                                                      By : Yasmine Sherif Mahmoud
                                                                                                                           Tutorial Code: APS-06-2012




All Copy Rights Saved to the 7th Students’ Conference on Communication and Information Based in the Faculty of Computers
and Information Cairo University – Egypt 2011/2012 www.scci-cu.com
• We will continue on our last project to add a
  splash screen with a timer to it.
• A splash screen is the first screen you see
  when you open the application.
• It disappears after an interval of time.
• Open your last project and follow these steps:
I added the new picture that I want to use as a splash screen in
my drawable file.
You can add a new picture as we have learned before in the
previous tutorials.
Here is the new picture.
Do not forget to clean your project so
you can be able to see the picture.
Right Click on layout
We will
                      delete this
                      part of code

Open the .Java file
Type R. and it
will give you
these options,
Choose layout
After choosing the
layout , type . then
it will give you these
options.
Choose
splash_screen
This is how you reference a your .xml file
• We are now accessing the Splash screen.xml
  but we can’t access the main.xml file anymore
  so we will have to create another .java file to
  access the main.xml file again at the same
  time of accessing the splash screen.xml file.
• Steps:
Right Click on your
project
This is how it going to look like.
We will have to add some code here to access
the main.xml file
2-Copy this line




1-Open the old .Java file
2- Paste the line you
                        copied before here

                  3- Write extends Activity

1- Back to the new .Java file
Right Click between
the parenthesis
This list will show up.
This will be auto generated as we used an already
implemented class to use the function that will
access the main.xml file
Write this line to finally
access the main.xml file
Go to the new splash_screen.xml file to add some code to it.
Open a tag < and write i the following
list will appear choose ImageView
Inside the Image view
Write android: and choose android:src from the list
which will appear
Reference the picture you
want to use like that
Write android:la and choose
android:layout_width from the list which will
appear
Write fill_parent so
that the picture will fill
the width of the
screen.
Write android:la and choose
android:layout_height from the list which will
appear
This is how the code is going to
look like
When closing any file
don’t forget to save the
changed you have made.
• Now according the application life cycle
  (Shown next slide), we have to add all the
  functions that the application carry out.
• So now we are going to add all these functions
  in our code:
Open your old .Java file
Right Click in the body
of the class and this list
will appear
This is where you are going to choose all
the functions that are found in the
application life cycle.
This is how they going to look like
after over riding them.
• After that we have to create the timer:
Write this line under
              here
Put a semi colon after this parenthesis
Write this
code
Write the following
code inside this class
It’s a while loop that
                 operates the timer



Write this line after the while loop but inside the try
body.
        Copy your package name.CLEARSCREEN
        in the brackets after Intent(“ ”)
You will have in error in the word Intent
which can be fixed by using this:
Add this code after
the try body
Add this line after the thread body
You will have an error
here which can be
handled by adding a catch
to the try
This will be auto
generated, choose
the first option.
2-Copy the shaded part




1- Go to the Manifest.xml file
Paste it under itself
Change the android:name to
.Mymain (the new .java file
you created before)
Change the name to “your
package
name.CLEARSCREEN”
Change it to .DEFAULT
The code after the
modifications.
• Save and Run.
Splash screen
successfully appeared 
• After 5 seconds , this screen will disappear
  and the next screen will be shown.
Yasmine Sherif EL-Adly



 @YasmineSherif91



+Yasmine Sherif EL-Adly

More Related Content

Similar to Android application (how to add a splash screen with timer) tutorial #4

PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdfPERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
arfa442827
 
Cis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interfaceCis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interface
sdjdskjd9097
 
Cis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interfaceCis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interface
ccis224477
 

Similar to Android application (how to add a splash screen with timer) tutorial #4 (20)

Introduction to Android and Java.pptx
Introduction to Android and Java.pptxIntroduction to Android and Java.pptx
Introduction to Android and Java.pptx
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
 
How to build your own Android App -Step by Step Guide
How to build your own Android App -Step by Step GuideHow to build your own Android App -Step by Step Guide
How to build your own Android App -Step by Step Guide
 
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdfPERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
 
Tutorial How to change the icon
Tutorial How to change the iconTutorial How to change the icon
Tutorial How to change the icon
 
Android app development guide for freshers by ace web academy
Android app development guide for freshers  by ace web academyAndroid app development guide for freshers  by ace web academy
Android app development guide for freshers by ace web academy
 
Project anatomy & hello world
Project anatomy & hello worldProject anatomy & hello world
Project anatomy & hello world
 
Hello android example.
Hello android example.Hello android example.
Hello android example.
 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
 
Cis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interfaceCis247 i lab 1 of 7 creating a user interface
Cis247 i lab 1 of 7 creating a user interface
 
Homework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12thHomework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12th
 
Using splash screens in java me applications
Using splash screens in java me applicationsUsing splash screens in java me applications
Using splash screens in java me applications
 
Cis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interfaceCis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interface
 
Animation
AnimationAnimation
Animation
 
AWS UG Warsaw & Serverless warsztatowo! 19.09.2019 | Hillel Solow's presentation
AWS UG Warsaw & Serverless warsztatowo! 19.09.2019 | Hillel Solow's presentationAWS UG Warsaw & Serverless warsztatowo! 19.09.2019 | Hillel Solow's presentation
AWS UG Warsaw & Serverless warsztatowo! 19.09.2019 | Hillel Solow's presentation
 
"Don’t Run with Scissors: Serverless Security Survival Guide" | Hillel Solow,...
"Don’t Run with Scissors: Serverless Security Survival Guide" | Hillel Solow,..."Don’t Run with Scissors: Serverless Security Survival Guide" | Hillel Solow,...
"Don’t Run with Scissors: Serverless Security Survival Guide" | Hillel Solow,...
 
AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...
AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...
AWS DeepLens Workshop: Building Computer Vision Applications - BDA201 - Atlan...
 
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
 

Recently uploaded

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 

Android application (how to add a splash screen with timer) tutorial #4

  • 1. Android Application Tutorial How to add a splash screen with a timer Instructed on: 02-Mar-2012 | Tutorial: #06 6  By : Yasmine Sherif Mahmoud Tutorial Code: APS-06-2012 All Copy Rights Saved to the 7th Students’ Conference on Communication and Information Based in the Faculty of Computers and Information Cairo University – Egypt 2011/2012 www.scci-cu.com
  • 2. • We will continue on our last project to add a splash screen with a timer to it. • A splash screen is the first screen you see when you open the application. • It disappears after an interval of time. • Open your last project and follow these steps:
  • 3. I added the new picture that I want to use as a splash screen in my drawable file. You can add a new picture as we have learned before in the previous tutorials.
  • 4. Here is the new picture. Do not forget to clean your project so you can be able to see the picture.
  • 5. Right Click on layout
  • 6.
  • 7.
  • 8. We will delete this part of code Open the .Java file
  • 9. Type R. and it will give you these options, Choose layout
  • 10. After choosing the layout , type . then it will give you these options. Choose splash_screen
  • 11. This is how you reference a your .xml file
  • 12. • We are now accessing the Splash screen.xml but we can’t access the main.xml file anymore so we will have to create another .java file to access the main.xml file again at the same time of accessing the splash screen.xml file. • Steps:
  • 13. Right Click on your project
  • 14.
  • 15. This is how it going to look like. We will have to add some code here to access the main.xml file
  • 16. 2-Copy this line 1-Open the old .Java file
  • 17. 2- Paste the line you copied before here 3- Write extends Activity 1- Back to the new .Java file
  • 18. Right Click between the parenthesis This list will show up.
  • 19.
  • 20.
  • 21. This will be auto generated as we used an already implemented class to use the function that will access the main.xml file
  • 22. Write this line to finally access the main.xml file
  • 23. Go to the new splash_screen.xml file to add some code to it.
  • 24. Open a tag < and write i the following list will appear choose ImageView
  • 25. Inside the Image view Write android: and choose android:src from the list which will appear
  • 26. Reference the picture you want to use like that
  • 27. Write android:la and choose android:layout_width from the list which will appear
  • 28. Write fill_parent so that the picture will fill the width of the screen.
  • 29. Write android:la and choose android:layout_height from the list which will appear
  • 30. This is how the code is going to look like
  • 31. When closing any file don’t forget to save the changed you have made.
  • 32. • Now according the application life cycle (Shown next slide), we have to add all the functions that the application carry out.
  • 33.
  • 34. • So now we are going to add all these functions in our code:
  • 35. Open your old .Java file
  • 36. Right Click in the body of the class and this list will appear
  • 37. This is where you are going to choose all the functions that are found in the application life cycle.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42. This is how they going to look like after over riding them.
  • 43. • After that we have to create the timer:
  • 44. Write this line under here Put a semi colon after this parenthesis
  • 46. Write the following code inside this class
  • 47. It’s a while loop that operates the timer Write this line after the while loop but inside the try body. Copy your package name.CLEARSCREEN in the brackets after Intent(“ ”)
  • 48. You will have in error in the word Intent which can be fixed by using this:
  • 49. Add this code after the try body
  • 50. Add this line after the thread body
  • 51. You will have an error here which can be handled by adding a catch to the try
  • 52. This will be auto generated, choose the first option.
  • 53. 2-Copy the shaded part 1- Go to the Manifest.xml file
  • 54. Paste it under itself
  • 55. Change the android:name to .Mymain (the new .java file you created before)
  • 56. Change the name to “your package name.CLEARSCREEN”
  • 57. Change it to .DEFAULT
  • 58. The code after the modifications.
  • 59. • Save and Run.
  • 60.
  • 62. • After 5 seconds , this screen will disappear and the next screen will be shown.
  • 63.
  • 64.
  • 65. Yasmine Sherif EL-Adly @YasmineSherif91 +Yasmine Sherif EL-Adly