Friday, June 21, 2013

Android 1: Lesson 7

Android 1: Lesson 7: Icon, Logo, and Start up music


INTRODUCTION
In this lesson you will be using photoshop, or another photo editor. And you will be changing the icon of the app. And adding a logo, of your choosing, to your application.
LESSON OBJECTIVES
By the end of this lesson, you will be able to:
1. Adding Icon
2. Adding Music
3. Adding Logo
LEARNING SEQUENCE


Required Reading
Read the following:
Introduction To Development Environment
·        Eclipse
·        Android
·        Considerations for beginning programming.
Resources
View the following:
1.      Eclipse
2.     Android Development
3.    Photo Editor Software
Assignments
Icons
  1. First, for the icons, you’ll want to make sure that the icons are the correct size.
  2. Find your workspace folder on your hard drive or flash drive and open it. It won’t work if you drag and drop the pictures into eclipse
  3. Within the workspace folder, you’ll see your app folder
  4. Open up the app folder and you’ll see a few folders and some other icons. Double click on the res folder
  5. Here you’ll see 5 ‘drawable’ folders, with different name following them. These are the icons for the app, differing on the type of screen the phone is
  6. Open the pictures in any photo editing software and change them to anyway you please
  7. When you save the pictures, make sure that they are the correct size, and that they are .png pictures
Logo
  1. For the logo, we’ll be displaying an image and playing a sound for a bit before the app officially opens
  2. In any photo editor, make an image that is 400x600, this will be your background. Make sure it’s a .png
  3. In any of the ‘drawable’ folders, you can place the background. The picture’s name should be something simple so you can type it out easily in java
  4. Now create a new folder within the res folder called ‘raw’ And place any song that you want inside the folder, this will be the song that is played at the very beginning when the app opens up.
  5. Now open eclipse and go to the layout folder. Create a new xml.
  6. Right click on the ‘layout’ folder. Move your mouse to ‘New’ and then select ‘Android XML File’
  7. Name it whatever you want, I chose logo.
  8. After ‘android:orientation’, you’ll want to add the piece of code ‘android:background=”@drawable/*whatever you named your background*” ‘
  9. Now you need to make the java for it, move to ‘com.example.test’ and right click it and select new, and click class. Name the Java ‘Logo’
  10. The file should open. You’ll want to move down to the ‘public class’ and type ‘extends Activity. They hover over the error and import the Activity.
  11. Move the cursor down past the ‘{‘ and hit enter. Type ‘MediaPlayer ourSong;’ import MediaPlayer.
  12. Hit enter and right click under ‘MediaPlayer’ Hover down to ‘Source’ and click on ‘Override/Implement Methods’
  13. Under ‘Activity’, you’ll want to select ‘onCreate(Bundle)’ and hit ok.