Skip to content

Commit cefd148

Browse files
authored
Merge pull request #341 from daniellevass/gh-pages
add more android tutorials
2 parents df9b509 + d9d738c commit cefd148

5 files changed

Lines changed: 150 additions & 1 deletion

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
layout: page
3+
title: Android Dev - Activity Lifecycle
4+
---
5+
6+
(this is a mini tutorial that can be completed at any time)
7+
8+
## 1. Intro
9+
10+
The aim of this tutorial is to look at how the activity lifecycle works which looks like this:
11+
12+
13+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_E25ED0FC0DF5A9B6B084CB936BAE886D8F9B2E37A2183F438D75F8F9BC39F410_1487708990139_file.png)
14+
15+
> for more information take a look at https://developer.android.com/guide/components/activities/activity-lifecycle.html There's also a really great video by Kristin Marsicano https://realm.io/news/activities-in-the-wild-exploring-the-activity-lifecycle-android/
16+
17+
## 2. Logging
18+
19+
Firstly, we’re going to implement the different activity lifecycle methods. Android Studio has a lot of keyboard shortcuts which will write a lot of the code for us! On Mac OS Z press `Command + N` and on Windows press `Alt + Insert` . Here you can select `Override methods` and find the methods listed above.
20+
21+
We’re then going to write ourselves some Log messages. If you’ve ever written any JavaScript, this is the same as `console.log` . These we can check in the Android Monitor (probably a button at the bottom of your window in Android Studio) which methods are being called.
22+
23+
When you first look in the Android Monitor, you’ll notice **a lot** of messages coming through. We can filter out which ones we care about by using a tag, like so:
24+
25+
26+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_E25ED0FC0DF5A9B6B084CB936BAE886D8F9B2E37A2183F438D75F8F9BC39F410_1487710556648_Screen+Shot+2017-02-21+at+20.55.42.png)
27+
28+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_E25ED0FC0DF5A9B6B084CB936BAE886D8F9B2E37A2183F438D75F8F9BC39F410_1487709397176_test.png) As you write a log message inside each method, speak to your coach about when you think this might get called!
29+
30+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_E25ED0FC0DF5A9B6B084CB936BAE886D8F9B2E37A2183F438D75F8F9BC39F410_1487708752616_Screen+Shot+2017-02-21+at+20.25.28.png)
31+
32+
> this is what my code looks like
33+
34+
Run this on a real device (or an emulator) and test it out and answer with your coach the following questions:
35+
36+
a. What methods get called when the app first starts up?
37+
b. What methods get called if I go home and come back into the app?
38+
c. What methods get called if I kill the app, and then open it again?
39+
40+
## 3. Gotchas
41+
42+
Which methods get called if you rotate your device?
43+
44+
Is that what you expected?
45+
46+
What other things could you do to your device that might destroy and re-create your activity? (Hint: changing the language)
47+
48+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_E25ED0FC0DF5A9B6B084CB936BAE886D8F9B2E37A2183F438D75F8F9BC39F410_1487709473122_test.png) Speak to your coach about your coach and see where they’ve learned the hard way about the activity lifecycle! Has it ever caused an app they’ve written to crash, or behave in a way they didn’t intend for?
49+
50+
## 4. Pop quiz
51+
52+
For the following questions, do you think they are true or false?
53+
54+
55+
1. After **onCreate**, the activity is now visible to the user to interact with.
56+
2. **onStart** always gets called every time the user comes back into the activity.
57+
3. **onResume** always gets called when you return to the activity, regardless of whether you killed the activity or just briefly left it.
58+
4. an activity in **onPause** can still be visible on the screen.
59+
5. **onDestroy** is the best place to save anything a user did so they can see it when they come back.
60+
61+
62+
Answers:
63+
64+
ǝnɹʇ ˙ʇɐƃnou uı sddɐ pǝʍopuıʍ ıʇןnɯ 'ǝnɹʇ 4 ˙ǝnɹʇ 3 ˙ǝsןɐɟ 2 ˙ǝɯnsǝɹuo ɹǝʇɟɐ s’ʇı 'ǝsןɐɟ 1

android/0layouts/tutorial.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
layout: page
3+
title: Android Dev - Layouts
4+
---
5+
6+
(this is a mini tutorial that can be completed at any time)
7+
8+
## 1. Intro
9+
10+
The aim of this worksheet is to demonstrate how to position elements by building an “about” page. We will also look at how we can apply the same style to elements that are very similar.
11+
12+
![](https://i.imgur.com/uiBO8Ial.png])
13+
> here’s how my about page looked at the end
14+
15+
16+
## 2. New layout resource
17+
18+
First, we need to create a new layout file. To do this, right click on your layout folder (inside resources) in Android Studio. You want to select a `layout resource file` . You should get a dialog popup like so:
19+
20+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_F796CF6A0040ADCCBAB2B9B20BC5945521E219A338BC472B843F87820F2EE3E3_1487608985363_Screen+Shot+2017-02-20+at+16.42.54.png)
21+
22+
> here you want to write the name of the file at the top, and then press ok! We don’t need to worry about the any of the available qualifiers!
23+
24+
25+
## 4. Building the layout
26+
27+
Next, we need to then start building the your profile card! Ideally, you need to put up between three and five pieces of information, such as your twitter account, linked in profile, public website!
28+
29+
https://d2mxuefqeaa7sj.cloudfront.net/s_F796CF6A0040ADCCBAB2B9B20BC5945521E219A338BC472B843F87820F2EE3E3_1487623536028_Screen+Shot+2017-02-20+at+20.45.15.png
30+
31+
32+
Experiment with the following attributes to position elements exactly where you want them:
33+
34+
- align
35+
- margin
36+
- padding
37+
38+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_F796CF6A0040ADCCBAB2B9B20BC5945521E219A338BC472B843F87820F2EE3E3_1487764459586_test.png) Try to work through positioning an element once on your own, then ask your coach for some feedback on how they might’ve positioned it. Learn from that and then work on the next element!
39+
40+
41+
## 5. Styles
42+
43+
After filling in a couple of pieces of information, you’ve probably started copying and pasting whole sections of layout code. Wouldn’t it be nicer if there was a better way to do this?
44+
45+
Fortunately, in Android we can use apply a style. A style will apply a bunch of attributes that you specify to any element you want. For example, our text is the same text size, and colour. We can specify those in a style!
46+
47+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_F796CF6A0040ADCCBAB2B9B20BC5945521E219A338BC472B843F87820F2EE3E3_1487621977280_Screen+Shot+2017-02-20+at+20.14.27.png)
48+
49+
> the code before
50+
51+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_F796CF6A0040ADCCBAB2B9B20BC5945521E219A338BC472B843F87820F2EE3E3_1487624799339_Screen+Shot+2017-02-20+at+21.06.25.png)
52+
53+
> my style 🎉
54+
55+
56+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_F796CF6A0040ADCCBAB2B9B20BC5945521E219A338BC472B843F87820F2EE3E3_1487621986762_Screen+Shot+2017-02-20+at+20.18.26.png)
57+
58+
> the code after!
59+
60+
61+
## 7. Finishing
62+
63+
Make sure you test out your design on different phones, and different orientations! How will you make it work on a really tiny device and a really big device?
64+
65+
![](https://d2mxuefqeaa7sj.cloudfront.net/s_F796CF6A0040ADCCBAB2B9B20BC5945521E219A338BC472B843F87820F2EE3E3_1487764549342_test.png) Speak to your coach if you’d like advice on how we handle supporting many different device sizes. For more information take a look at https://developer.android.com/guide/practices/screens_support.html

android/0resources/tutorial.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
layout: page
3+
title: Sources for Android Development
4+
---
5+
6+
Everyone will need **Android Studio** - https://developer.android.com/studio/index.html
7+
8+
If you’d like to pick it up on your own, the **Big Nerd Ranch** have a really very good book to pick up Android (they have an iOS book too) - https://www.bignerdranch.com/we-write/
9+
10+
**Amal** has written a more advanced android tutorial located at https://github.com/K4KYA/MakersHelloAndroid/tree/codebar if you want to take Android even further :)
11+
12+
**Google** also has their own tutorial series at https://developer.android.com/training/basics/firstapp/index.html, which touches on some of the details and complexities of Android app development - saving data, sharing things with other apps, getting location data and other things you may want a more complex app to be able to do.
13+
14+
**Udacity** also have a super course available which women can apply for a scholarship here https://www.udacity.com/google-scholarships
File renamed without changes.

index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,15 @@ <h3>Other Recommended Python Resources</h3>
8888

8989
<h2>Android</h2>
9090
<ul>
91-
<li><a href="android/introduction/tutorial.html">Lesson 1 -
91+
<li><a href="android/0resources/tutorial.html">Resources</a></li>
92+
<li><a href="android/1introduction/tutorial.html">Lesson 1 -
9293
Introduction to Android Development with Cookie
9394
Clicker</a></li>
95+
<li><a href="android/0activity-lifecycle/tutorial.html">Misc -
96+
the Android Lifecycle</a></li>
97+
<li><a href="android/0layouts/tutorial.html">Misc -
98+
layouts to build a profile page
99+
</a></li>
94100
</ul>
95101

96102
<h2>PHP</h2>

0 commit comments

Comments
 (0)