Components of Android
Components of Android
Components of Android
Project
Main Building Blocks/Main components
behind any Android Application
Activity
Activity Lifecycle
Activity Lifecycle
Method Description
onCreate called when activity is first created.
onStart called when activity is becoming visible to the user.
onResume called when activity will start interacting with the user.
– Bound Service
It is a kind of service which runs till the lifespan of the activity which started
this service
Content Providers
Type a statement,
press Ctrl + Shift + Enter (Cmd + Shift + Enter on OS X),
and notice how the closing punctuation is automatically
added (If you press these keys after typing).
Debugging Application
Debugging Application
Android Studio provides a debugger that lets you do the following and
more;
Select a device to debug your app on.
Set breakpoints in your Java, Kotlin, and C/C++ code.
Examine variables and evaluate expressions at runtime.
https://developer.android.com/studio/intro#code_completion
Android Studio Features
A flexible Gradle-based build system
A fast and feature-rich emulator
A unified environment where you can develop for all Android devices
Live Edit to update composables in emulators and physical devices in real
time
Code templates and GitHub integration to help you build common app
features and import sample code
Extensive testing tools and frameworks
Lint tools to catch performance, usability, version compatibility, and other
problems
C++ and NDK support
Built-in support for Google Cloud Platform, making it easy to integrate Google
Cloud Messaging and App Engine
Project Structure
Each project in Android Studio contains one or more modules with source
code files and resource files. The types of modules include;
Android app modules
Library modules
Google App Engine modules
To see the actual file structure of the project, select Project instead of
Android from the Project menu.
Gradle Build System
Android Studio uses Gradle as the foundation of the build system,
with more Android-specific capabilities provided by the Android
Gradle plugin. This build system runs as an integrated tool from the
Android Studio menu and independently from the command line.
You can use the features of the build system to do the following;
Customize, configure, and extend the build process.
Create multiple APKs for your app with different features, using the same
project and modules.
Reuse code and resources across source sets.
By employing the flexibility of Gradle, you can achieve all of this without
modifying your app's core source files.
Build variants
The build system can help you create different versions of the same
app from a single project.
This is useful when you have both a free version and a paid version of
your app or if you want to distribute multiple APKs for different
device configurations on Google Play.
Multiple APK support
Multiple APK support lets you efficiently create multiple APKs based
on screen density or ABI.
For example, you can create separate APKs of an app for the hdpi and
mdpi screen densities, while still considering them a single variant
and letting them share test APK, javac, dx, and ProGuard settings.
Resource Shrinking
For example, if your app uses Google Play services to access Google
Drive functionality, and you are not currently using Google Sign-In,
then resource shrinking can remove the various drawable assets for
the SignInButton buttons.
Inline debugging
Use inline debugging to enhance your code walkthroughs in the
debugger view with inline verification of references, expressions,
and variable values.
To enable inline debugging, in the Debug window, click Settings
and select Show Variable Values in Editor.
Performance Profilers
The Android SDK tools, such as Systrace and Logcat, generate performance
and debugging data for detailed app analysis.
The lint tool checks your Android project source files for potential bugs and
optimization improvements for correctness, security, performance, usability,
accessibility, and internationalization.
Annotations in Android Studio
When you build and run your app with Android Studio, you can view adb
output and device log messages in the Logcat window.
Sign in to your developer account
Sign in to your developer account in Android Studio to access additional tools
that require authentication, such as Firebase. By signing in, you give those
tools permission to view and manage your data across Google services.
Once you open a project in Android Studio, you can sign in to your developer
account or switch developer accounts as follows;
1. Click the profile icon at the end of the toolbar.
2. In the window that appears, do one of the following;
If you're not yet signed in, click Sign In and allow Android Studio to access the
listed services.
If you're already signed in, click Add Account to sign in with another Google
account.
Alternatively, you can click Sign Out and repeat the previous steps to sign in to a
different account.