1. This work is licensed under the Apache 2.0 License
Day 2
Android Studio
2. This work is licensed under the Apache 2.0 License
Community Page
3. This work is licensed under the Apache 2.0 License
a
Our Social Handles
GDSC_ICOER
4. What We Did In Last Session
This work is licensed under
the Apache 2.0 License
5. This work is licensed under the Apache 2.0 License
What is Kotlin?
● Kotlin is a programming language
developed by JetBrains.
● Kotlin was made open source in the year
2011.
● Previously Java was considered as the
official language of Android Development.
6. This work is licensed under the Apache 2.0 License
Function Declaration
We have to use the fun keyword for declaring
any function.
Syntax:
fun function_name()
{
//Statements or code.
}
7. This work is licensed under the Apache 2.0 License
Conditions
Conditional statements decide the flow of program
There are four types of conditional statements:
1) If : The block will only execute if the condition is true
fun main() {
var a=5
if(a==5)
println(“Five”)
}
8. This work is licensed under the Apache 2.0 License
Conditions
2) If else: The if block will execute only when the condition is true
otherwise the else block will get executed.
//Even Or Odd
fun main() {
var a=5
if(a%2==0)
println(“Even”)
else
println(“Odd”)
}
9. This work is licensed under the Apache 2.0 License
Conditions
3) If else if else:
//Even Or Odd Or Zero
fun main() {
var a=5
if(a==0)
println(“Zero”)
else if(a%2==0)
println(“Even”)
else
println(“Odd”)
}
10. This work is licensed under the Apache 2.0 License
Conditions
4) If else:
//Even Or Odd Or Zero
fun main() {
var a=5
if(a==0)
println(“Zero”)
else
{
if(a%2==0)
println(“Even”)
else
println(“Odd”)
}
}
11. This work is licensed under the Apache 2.0 License
Conditions
5) Nested if:
fun main() {
var a=5
if(a%2!=0) {
if(a>=5) {
println(“Can be five or greater”)
}
}
}
12. 6) When Statement:
When statement is used to remove the extra use of conditional
statements.
Let us design a calculator
Example:
fun main() {
var a:Int = 5
var b:Int =3
var c:Char=’+’
}
14. This work is licensed under the Apache 2.0 License
Introduction to Android Studio
Android Studio is the official Integrated Development Environment (IDE) for
Android app development, based on IntelliJ IDEA .
Android Studio offers even more features that enhance your productivity when
building Android apps
15. This work is licensed under the Apache 2.0 License
Requirements For Android
Studio
The following are the system requirements for Android
Studio on Windows.
● 64-bit Microsoft® Windows® 8/10/11
● x86_64 CPU architecture; 2nd generation Intel Core
or newer, or AMD CPU with support for a Windows
Hypervisor
● 8 GB RAM or more
● 8 GB of available disk space minimum (IDE + Android
SDK + Android Emulator)
● 1280 x 800 minimum screen resolution
16. This work is licensed under the Apache 2.0 License
Set up Android
Studio :)
Install and set up Android Studio, so
that you can create your own projects
and run them on a device or emulator.
17. This work is licensed under the Apache 2.0 License
Step 1 : Download Android Studio
1. Open any web browser and navigate to the Android Studio download page.
Click Download Android Studio. The Terms and Conditions page with the Android Studio License Agreement
opens.
2. Click Download Android Studio to start the download.
3. When prompted, save the file to a location where you can easily locate it, such as the Downloads
folder.
4. Download -> Save -> Install -> Create!
18. This work is licensed under the Apache 2.0 License
Step 2 :- Install Android Studio
19. This work is licensed under the Apache 2.0 License
Choose Your
Preferred UI
Theme.
Step 2 : Install Android
Studio
20. This work is licensed under the Apache 2.0 License
Step 2 : Install Android Studio
21. This work is licensed under the Apache 2.0 License
Congratulations! You've
successfully installed
Android Studio. Now
you're ready for the next
step! 🥳
Step 2 : Install Android
Studio
22. This work is licensed under the Apache 2.0 License
Android Studio
23. This work is licensed under the Apache 2.0 License
Step 3 : Create First Project
1. Double click the Android Studio icon to launch Android Studio.
24. This work is licensed under the Apache 2.0 License
Step 3 : Create First Project
2. In the Welcome to Android Studio dialog, click New Project.
25. This work is licensed under the Apache 2.0 License
Step 3 : Create First Project
3. From the list of templates provided by Android Studio Select Phone and Tablet tab is
selected.
26. This work is licensed under the Apache 2.0 License
Step 3 : Create First Project
4. Fill the required information.
5. Hit Finish. This may take a while
27. This work is licensed under the Apache 2.0 License
Step 3 : Create First Project
6. You may see a What's New pane which contains updates on new features in Android Studio.
Close it for now.
28. This work is licensed under the Apache 2.0 License
Step 3 : Create First Project
7. Click Split on the top right of Android Studio, this allows you to view both code and
design.After pressing Split you should see three areas.
29. This work is licensed under the Apache 2.0 License
Step 3 : Create First Project
8. In the Design view, you will see a blank pane with this text
30. This work is licensed under the Apache 2.0 License
Step 3 : Create First Project
9. Click Build & Refresh. It may take a while to build but when it is done the preview shows a text
box that says "Hello Android!".
31. This work is licensed under the Apache 2.0 License
Step 4 : Set Up Android Emulator
1. In Android Studio, select Tools > Device Manager.
32. This work is licensed under the Apache 2.0 License
Step 4 : Set Up Android Emulator
2. Click Create Virtual Device.
33. This work is licensed under the Apache 2.0 License
Step 4 : Set Up Android Emulator
3. Select Phone as the category.
4. Select a phone, such as the Pixel 5, and then click Next.
5. If there's a download link next to S, click Download > Accept > Next > Finish.
34. This work is licensed under the Apache 2.0 License
Step 4 : Set Up Android Emulator
6. In the Recommended tab, choose S as the version of Android to run on the virtual device.
35. This work is licensed under the Apache 2.0 License
Step 4 : Set Up Android Emulator
This action opens another screen, where you can choose additional configuration details for
your device.
36. This work is licensed under the Apache 2.0 License
Step 4 : Set Up Android Emulator
7. In the AVD Name field, enter a name for your AVD or use the default. Leave the rest of
the fields unchanged.
8. Click Finish.
37. This work is licensed under the Apache 2.0 License
Android Studio
Emulator
Default Preview
Corporate needs you to find the differences between
this picture and this picture.
38. This work is licensed under the Apache 2.0 License
Run your first app on the Android Emulator
1. Select the virtual device that you created from the dropdown
menu at the top of the Android Studio window.
39. This work is licensed under the Apache 2.0 License
Run your first app on the Android Emulator
2. Click
40. This work is licensed under the Apache 2.0 License
Run your first app on the Android Emulator
41. This work is licensed under the Apache 2.0 License
Run your first app on the Android Emulator
When your app is ready, it opens on the virtual device.
42. This work is licensed under the Apache 2.0 License
How to connect your Android device
1. On your Android device, tap Settings > About phone.
2. Tap Build number seven times.
3. If prompted, enter your device password or pin. You know you
succeeded when you see a You are now a developer! message.
43. This work is licensed under the Apache 2.0 License
How to connect your Android device
4. Return to Settings and then tap System > Developer options.
5. If you don't see Developer options, tap Advanced options.
44. This work is licensed under the Apache 2.0 License
How to connect your Android device
6. Tap Developer options and then tap the USB debugging toggle to turn it on.
45. This work is licensed under the Apache 2.0 License
How to connect your Android device
Install the Google USB Driver (Windows only)
1. In Android Studio, click Tools > SDK Manager. The Preferences > Appearance & Behavior System
Settings > Android SDK dialog opens.
2. Click the SDK Tools tab.
3. Select Google USB Driver and then click OK.
46. This work is licensed under the Apache 2.0 License
Run your app on the Android device with a cable
1. Connect your Android device to your computer with a USB cable. A dialog should
appear on your device, which asks you to allow USB debugging.
47. This work is licensed under the Apache 2.0 License
Run your app on the Android device with a cable
1. Select the Always allow from this computer checkbox and then tap OK.
2. In Android Studio on your computer, make sure your device is selected in the dropdown.
3. Click
4. Select your device and then click OK. Android Studio installs the app on your device
and runs it.
5. If your device runs an Android platform that isn't installed in Android Studio and you
see a message that asks whether you want to install the needed platform, click Install
> Continue > Finish. Android Studio installs the app on your device and runs it.
48. This work is licensed under the Apache 2.0 License
Run your app on the Android device with Wi-Fi
Get started
1. Ensure that your computer and device are connected to the same wireless network.
2. Ensure that your device runs Android 11 or higher. For more information, see Check &
update your Android version.
3. Ensure that your computer has the latest version of Android Studio. To download it,
see Android Studio.
4. Ensure that your computer has the latest version of the SDK Platform Tools.
49. This work is licensed under the Apache 2.0 License
Run your app on the Android device with Wi-Fi
1. In Android Studio, select Pair Devices Using Wi-Fi from the run configurations drop-down
menu.
50. This work is licensed under the Apache 2.0 License
The Pair devices over Wi-Fi dialog opens.
Run your app on the
Android device with
Wi-Fi
51. This work is licensed under the Apache 2.0 License
Run your app on the Android device with Wi-Fi
2. Go to Developer options, scroll down to the Debugging section and turn on Wireless
debugging.
52. This work is licensed under the Apache 2.0 License
Run your app on the Android device with Wi-Fi
3. On the Allow wireless debugging on this network? popup, select Allow.
53. This work is licensed under the Apache 2.0 License
Run your app on the Android device with Wi-Fi
4. If you want to pair your device with a QR code, select Pair device with QR code and
then scan the QR code on your computer. Alternatively, if you want to pair your
device with a pairing code, select Pair device with pairing code and then enter the
6-digit code.
5. Click run and you can deploy your app to your device.