Presentation is loading. Please wait.

Presentation is loading. Please wait.

Android Application Development 2013 PClassic Chris Murphy 1.

Similar presentations

Presentation on theme: "Android Application Development 2013 PClassic Chris Murphy 1."— Presentation transcript:

1 Android Application Development 2013 PClassic Chris Murphy 1

2 First things first: WiFi! 1. Connect to AirPennNet-Guest. 2. Open a web browser. You will be redirected to a login page: Click the link for the conference code registration form. 3. Enter your personal information, along with the registration code: C-JAYAMAFT 4. Once you hit continue, you will be granted access for 15 mins. You will, by then, get an email with a confirmation link (this link may be sent to spam). 5. Click the link, and you will get internet access for the full day. 2

3 Overview What is Android? Creating an Android app Basic Android user interfaces: forms Handling button clicks and user interaction Dialogs 3

4 What is Android? An open source Linux-based operating system intended for mobile computing platforms Includes a Java API for developing applications It is not a device or product 4

5 5

6 Creating an Android App 6

7 1.Set up your development environment 2.Create a new Android project in Eclipse 3.Implement it 4.Run it 7

8 1. Set Up Your Android Environment Install Eclipse Install Android SDK (Android libraries) Install ADT plugin (Android development tools) Create AVD (Android virtual device) 8

9 2. Create an Android Project in Eclipse File → New → Android Application Project Fill in Project details... After first screen, just keep choosing “Next” button 9

10 Name that appears on device Project directory Java package Android version 10

11 3. Run the Android Application Run → Run As… → Android Application If it says “No AVD Found” or something like that, create a new one from Window → Android Virtual Device Manager The emulator may take a few minutes to start, so be patient! 11

12 12

13 Android Basic UI: Forms 13

14 Layout Files Android uses XML files to specify the arrangement of elements in the UI Activity: Java class that corresponds to a screen Layout: specifies the position of elements View: a visible element in the UI 14

15 1. Navigate to here 2. Then click here 15

16 activity_main.xml 16

17 EditText TextView Button We want something like this… 17

18 1. Click here 2. Then drag this to the top 3. Then right click, select Edit Text, and change it 18

19 1. Drag two Buttons to the bottom 19

20 1. Right-click, select Edit Text, and change 2. Then click here 20

21 1. Drag this to the middle 2. Don’t forget to save it! 21

22 22 The Layout should look like this now

23 23 The XML should look like this

24 Helpful Hints: Running your app The Graphical Layout tool only helps you edit the layout; it doesn’t actually run your app After you've edited activity_main.xml, run the project as an Android app and you should see it (re-)appear in the emulator Don't close the emulator! You don't need to restart it every time you rebuild your app!! 24

25 Handling Button Clicks 25

26 Handling Button Clicks The activity_main.xml file also can specify the method that should be called when the user clicks a Button This method should reside in the Java class that extends Activity Pay close attention to details when implementing the button click method! 26

27 1. Click here 2. Add this line 27

28 1. Navigate to here and open the file 2. Then add this method 28

29 29

30 Helpful Hints: Accessing Views In the class that extends Activity, you can get access to the Views in its Layout by using the findViewById method, along with the ID that is specified in activity_main.xml You do need to cast the View to the appropriate subclass, however 30

31 31

32 32 Helpful Hints: Debugging Log.v(tag, message); Window > Show View > Other > Android > LogCat Stack traces go in LogCat, too To show a pop-up window: Toast.makeText( getApplicationContext(), message, Toast.LENGTH_LONG).show();

33 Dialogs 33

34 Dialogs Dialogs are pop-ups that have associated Buttons, which have associated actions (methods) Use a DialogBuilder to assemble the Dialog Note: the way I’m going to show you here is the “old” way (but it’s a bit easier) 34

35 1. Modify this line 3. Then add this method 2. Then this one 35

36 36

37 Helpful Hints: Activities Keep in mind that the class that extends Activity is just a regular old Java class Its methods can communicate via shared variables (aka “fields”) 37

38 1. Add this line 2. Add this line 3. Add/modify these three lines 4. Add this line 38

39 39

40 40

41 Just for fun! Add an “Are you ready?” Dialog that is shown when the app starts Hint: you’d need to call showDialog from the onCreate method Keep track of the best (lowest) time Randomly choose a sentence to display 41

42 Android Resources 42

43 Android Resources 43

44 Installing your app on a device You can use Eclipse to install your app via a wired connection with your device Or... go into the /bin directory of the Eclipse project, find the.apk file, email it to yourself, and install it on the device via your email client You can also upload the.apk file to to see how it would like on various other devices 44

45 45 Good luck today!

Download ppt "Android Application Development 2013 PClassic Chris Murphy 1."

Similar presentations

Ads by Google