Android Examples
A list of android samples on different topics!
Jetpack Compose
- (Kotlin) Basic ImageView and TextView in Jetpack Compose. Link
- (Kotlin) Creating a list with custom view holder with material theming. Link
- (Kotlin) Creating a chat list and maintaining local view states using remember and mutableState. Link
- (Kotlin) Compose permissions and Android Permissions. Link
Application Components
Activities & Fragments
- Fragment to Fragment communication through interfaces. Link
- (Kotlin) Activity and Fragment Lifecycles. Link
Services
- (Kotlin) Simple Foreground Service. Link
- (Kotlin) Start foreground service and stop it on device reboot.
- Foreground Service to control music playback. (Work in Progress) Link
Broadcast Receivers
- (Kotlin) Listen to all system broadcasts. Link
- (Kotlin) Send Broadcast on device reboot. Link
- (Kotlin) Send Local Broadcast from a JobIntentService. Link
- Send Local Broadcast from a JobIntentService. Link
Content Providers
Architecture Components
Data Binding & View Binding
View Model & Live Data
Paging
Work Manager
Room
- https://github.com/Singularity-Coder/Blog/tree/master/java/RoomNews
- https://github.com/Singularity-Coder/Blog/tree/master/java/Rooming
App & View Communication
- Sharing data between Fragments through Shared ViewModel. Link
- Sharing data between Fragments through Interfaces. Link
- Receive data from other Apps through Intent Filters. Link
Navigation Components
Android Networking
Ktor
- (Kotlin) Simple Github API call using Ktor Library. Link
Volley
- https://github.com/Singularity-Coder/Blog/tree/master/java/VolleyNetworking
- https://github.com/Singularity-Coder/Blog/tree/master/java/VolleyNetworkingGSON
- https://github.com/Singularity-Coder/Blog/tree/master/java/VolleyNetworkingPOST
Retrofit
- (Kotlin) Simple API call using Retrofit Library with GSON converter - Part 1. Link
- (Kotlin) Simple API call using Retrofit Library with GSON converter - Part 2. Link
- https://github.com/Singularity-Coder/Blog/tree/master/java/RetrofitResponseObject
- https://github.com/Singularity-Coder/Blog/tree/master/java/RetrofitPOSTwithGSON
- https://github.com/Singularity-Coder/Blog/tree/master/java/RetrofitGETwithGSON
- https://github.com/Singularity-Coder/Blog/tree/master/java/POSTRetrofitting
- https://github.com/Singularity-Coder/Blog/tree/master/java/Retrofitting
HttpUrlConnection
- Fetch list of restaurants from Zomato API using HttpUrlConnection. Link
Tools
- Chucker to monitor http network stuff. Link
Android Data Storage
- A simple Room ORM example without any views. Link
- Storing newsapi.org news API info into SQLite through Room ORM and Retrofit. Link
- A simple todo list app using Room ORM. Link
- Todo list app using raw SQLite. Link
- (Kotlin) Realm No-SQL local database. Link
Dependency Injection
- (Kotlin) DI using Dagger Hilt, Retrofit, Room,etc. (Under Construction) Link
Firebase
Cloud Messaging
- Firebase Cloud Messaging (FCM) example. Link
Authentication
Storage
- Store and retrieve files using Firebase Storage. Link
Firestore
- Create a Grocery List App by performing CRUD operations. Link
Social Integration
- https://github.com/Singularity-Coder/Blog/tree/master/java/FirebaseGoogleAuth
- https://github.com/Singularity-Coder/Blog/tree/master/java/GoogleAuth
Real-Time App Messaging
User Interface & User Experience
Shape Drawables, Fav Gradients, 9 patch images, material components, custom UI components, animations, transitions, canvas drawings, color palletes, custom styles, image scaling and transformation techniques, etc.
- https://github.com/Singularity-Coder/Blog/tree/master/java/ActionBarMenus
- https://github.com/Singularity-Coder/Blog/tree/master/java/AndroidAlertDialogs
- https://github.com/Singularity-Coder/Blog/tree/master/java/DateTimePickers
- https://github.com/Singularity-Coder/Blog/tree/master/java/FrescoImageView
- https://github.com/Singularity-Coder/Blog/tree/master/java/LottieAnimationsTutorial
- https://github.com/Singularity-Coder/Blog/tree/master/java/MutliViewList
- https://github.com/Singularity-Coder/Blog/tree/master/java/NavigationDrawer2
- https://github.com/Singularity-Coder/Blog/tree/master/java/RecyclerViewCustomHeader
- https://github.com/Singularity-Coder/Blog/tree/master/java/RxBindingViews
- https://github.com/Singularity-Coder/Blog/tree/master/java/ShimaShimaShima
- https://github.com/Singularity-Coder/Blog/tree/master/java/TabLayout
- https://github.com/Singularity-Coder/Blog/tree/master/java/ParallaxTabs
- https://github.com/Singularity-Coder/Blog/tree/master/java/LayoutParams
- https://github.com/Singularity-Coder/Blog/tree/master/java/OnClickListsners4Styles
- (Kotlin) https://github.com/Singularity-Coder/Blog/tree/master/kotlin/KotlinRecyclerView
- (Kotlin) https://github.com/Singularity-Coder/Android-Dialogs
- (Kotlin) Modal Bottom Sheet Link
- (Kotlin) Persistent Bottom Sheet Link
- (Kotlin) Multi Touch Link
Multi-Threading & Background Processing
Utilities
Camera
- https://github.com/Singularity-Coder/Blog/tree/master/java/CameraXTest
- https://github.com/Singularity-Coder/Blog/tree/master/java/CustCam
- https://github.com/Singularity-Coder/Blog/tree/master/java/QRCodeScanner
Other Utilities
- https://github.com/Singularity-Coder/Blog/tree/master/java/RecordScreenLikeCrazy
- https://github.com/Singularity-Coder/Blog/tree/master/java/ShareImageText
- https://github.com/Singularity-Coder/Blog/tree/master/java/ShoworHidePassword
- https://github.com/Singularity-Coder/Blog/tree/master/java/Pagination
- https://github.com/Singularity-Coder/Blog/tree/master/java/NotificationGenerator
- https://github.com/Singularity-Coder/Blog/tree/master/java/TextToSpeechToTextApp
- https://github.com/Singularity-Coder/Blog/tree/master/java/FilterRecyclerViewLocally
- https://github.com/Singularity-Coder/Blog/tree/master/java/AndroidSearch
- Perform recurring tasks with Timer, Handler, Observable Timer & Interval, etc. Link
- (Kotlin) Creating custom toast on android Link
- (Kotlin) Logging on Android Link
Machine Learning
JSON Parsing
- https://github.com/Singularity-Coder/Blog/tree/master/java/OfflineJSON2
- https://github.com/Singularity-Coder/Blog/tree/master/java/LocalJSON
Location Services
- https://github.com/Singularity-Coder/Blog/tree/master/java/PlacePicker
- https://github.com/Singularity-Coder/Android-Examples/tree/master/java/GetLatLong
- https://github.com/Singularity-Coder/Android-Examples/tree/master/java/GetLocationUpdates
- https://github.com/Singularity-Coder/Android-Examples/tree/master/java/Geofencing
Protocol Buffers
- (Kotlin) Construct a basic object using Protobuf. Link
- (Kotlin) Deserialise data coming from an API with Protobuf. (Work in Progress) Link
Java Native Interface (JNI)
- (Kotlin) Fetching strings from native code to Kotlin code using JNI. Link
Testing
Espresso Testing
- https://github.com/Singularity-Coder/Blog/tree/master/java/RoomNews
- https://github.com/Singularity-Coder/Blog/tree/master/java/RetrofitPOSTwithGSON
Unit Testing
Airbnb Epoxy
- Basic Recycler View with dummy data Link
RxJava
- https://github.com/Singularity-Coder/Blog/tree/master/java/RxJavaNews
- Perform click events using Jake Wharton's RxBinding Library. Link
Gradle
- (Kotlin) BuildType and Build Flavors Link
CI/CD
Android Games
Android Performance Tools
Android App Ads
Payment Integration
Other
Programming Paradigms in Android
Reactive Programming
Functional Programming
Object-oriented Programming
Declarative Programming
Imperative Programming
Procedural Programming
Logic Programming
Modular Programming
Structured Programming
Generic Programming
Event-driven Programming
Aspect-oriented Programming
Prototype based Programming
Data-driven Programming
Function-level Programming
Array Programming
Dataflow Programming
Role-oriented Programming
Agent-oriented Programming
Stack oriented Programming
SOLID Principles in Android
Sigle Responsibility
Open/Closed
Liskov Substitution
Interface Segregation
Dependency Injection
Design Principles in Android
Loose coupling
Prefer Composition over Inheritance
Program to an Interface, not an implementation
Encapsulate what varies
Encapsulation
Abstraction
Polymorphism
Inheritance
Design Patterns in Android
Creational Patterns
- Abstract Factory Pattern Link1
- Builder Pattern KotlinLink1
- Factory Method Pattern Link1 Link 2
- Prototype Pattern
- Singleton Pattern Link1
Structural Patterns
- Adapter Pattern
- Bridge Pattern
- Composite Pattern
- Decorator Pattern
- Facade Pattern Link1
- Flyweight Pattern
- Proxy Pattern
Behavioural Patterns
- Chain of Responsibility Pattern
- Command Pattern
- Interpreter Pattern
- Iterator Pattern
- Mediator Pattern
- Memento Pattern
- Observer Pattern
- State Pattern
- Strategy Pattern
- Template Pattern
- Visitor Pattern
Architecture Patterns in Android
- MVVM Architecture (Model View ViewModel) Link
- MVP Architecture (Model View Presenter) Link
- MVC Architecture (Model View Controller) Link
- VIPER Architecture (View Interactor Presenter Entity Router) Link
- MVI Architecture (Model View Intent)
- Clean Architecture
Android FAQ
I collected these questions from some medium article. I forgot to add the source at that time. I will attach it when I find it.
Activity/Fragment/Broadcast/Application/Service Lifecycle (Explain with one line description)
Which lifecycle method gets called when A goes to B/come back to A?Activity Launch Modes with examples
Let’s say 4 activities are there A->B->C->D. How to launch A from D finishing in between activities?
4 Activities are there A->B->C->D.How to finish application from D if none of the activities opened earlier finished till now?
How CLEAR_TOP flag intent works in android?
Service vs IntentService?When to prefer which type of service?
Explain ways for Activity to activity communication/Activity to fragment communication/Fragment to fragment communication.
How to make a service persist even after Application killed?
How to achieve Interprocess communication in android?
How Async task internally works? Async task implementation?
Cons of using Async task? How to overcome this limitation?
Why Job Scheduler?
Notification related changes in Oreo?
How to handle Background service and execution limits with new Oreo Updates?
Have you seen Google I/O 2018? What were the updates for Android there?
Why do we use Headless fragments?
Memory Leakage, Causes, and preventions in Android? I have written a blog out here.You can refer this too
Ways to optimize an Android Application.
Proguard-Obfuscation/ Minification, Build Variants, Flavours.
How to achieve MultiThreading in Android?
Suppose you have 10 images to fetch from Server. What is the best way to fetch images? (Hint: Read about ThreadPool and Executor)
Builder vs Factory Pattern with an example
Why MVP not MVC? They will ask you to make a wireframe kind of thing on paper to demonstrate MVP pattern in android.
Why RXJAVA so popular nowadays?
Problems in RXJAVA? They can provide you with some scenarios to get to know if you can find out the problems with it.
Map vs Flat map? (Most commonly asked in RXJAVA)
Should we provide a context in presenter/Model? Answering yes/no is not enough. You have to provide a solution for it.
Why Schedulers and How Rxjava internally works with them?SusbcribeOn vs ObserveOn, Schedulers on which both of these work?.subscribe(new Subscriber…) vs .subscribe(new Observer…)
IOScheduler/new Thread Scheduler in RXJava
How dagger internally worksDagger vs Dagger2? Explain the purpose of every annotation taken in Dagger2.
How do you decide scope in Dagger? Why Qualifier annotation?
Why do we use Handlers? Do you know the Loopers? What’s the role of Message queue? With this, they will go for Main Thread working. They will also ask you about the exceptions we get as Looper.prepare() exceptions
Cause of Memory leak during the Async Task?
Explain Singleton pattern. Problems with it and Handling. (hint: Double checked locking/synchronization)
Why do you prefer Retrofit over Volley? Why Picasso? Now they will ask all the third party libraries you have used. Be honest with your answer. They may go deep in any of those.
Why ConstraintLayout?Barriers vs Guidelines, Why Group/Chains?
Why do we prefer Framelayout for Fragments?
Why ANR?How to prevent it?
Do async.execute make threads in parallel or serial?
How to make a custom view in android? Explain lifecycle methods. Difference between onLayout/onMeasure.
Have you ever faced any issue with SingleInstance launch mode or example if you have used it? Providing real-life examples are preferred more.
When 1 fragment added over another-Explain lifecycle methods. Another question would be if you replace instead of adding it. The 3rd question will be if you have back stack there.
Why fragment newInstance() is there (Best practice for instantiating a new Android Fragment)
Suppose you have to update location every minute even if you don’t get permission. But the tricky thing here is how will you notify the server-Through the same service you were sending updates using FusedLocationProvider/Will you use some other service or broadcast. Just design the whole thing.
Observable.just/Observable.from/Observable.create in RXJAVA?
Why Instant Apps? How do you achieve this?
How to load Large Bitmaps? Handle Memory leaks and Sample sizing
How parcelable internally works? Design it.
What happens if your serializable class contains a member which is not serializable? How to handle it?
Why do we use WeakReferences?
How to retain data on orientation change? Explain lifecycle during orientation changes.
How to make endless circular recyclerView?
Suppose you have given an array of array of custom Objects. Which data structure will you use to show these on UI?
How do you handle opening activity using notifications?
How to achieve Push notifications in android? Explain behavior during App in front/Background-How to handle both scenarios.
How to download files in parallel?
Why Realm?Realm Methods, Realm vs Sqlite.
How to handle different screen sizes/density/languages/orientation in android?
What the Fragment’s method setRetainInstance(boolean) does?
Keep yourself up to date with the latest library versions if using.
Why is there a need for JobIntentService?(hint:: Oreo update)
Basics for Testing in Android-They will ask some questions about Espresso,mockito,roboelectric(not in that deep).Stub vs mock. Also if you are following MVP pattern. Be prepared for the questions now.
How the OS handles process flow. When is the app killed or removed from recent memory? How OS decides this.
Which method gets called when home button pressed, back pressed etc.(Most commonly asked)
Manifest related attributes -allowBackup,intent-filters,process,taskAffinity,permission vs uses-permission etc.
Draw a simple basic design you follow to make an android application(folder structure, methods, variables)
Why services preferred over Broadcast receiver for background applications
Broadcast-related changes in Oreo and Handling them.
Accessibility services in android. How do you handle system apps(I mentioned this work too, so asked)
Thread.start() vs run method,submit vs Execute ,callable vs runnable
View Holder pattern.ListView vs RecyclerView.
Remote Views and How to use them?
Inner Classes vs Static Classes?
Volatile vs Transient
Internal Implementation of Picasso, Glide
Internal implementation of Recyclerview
Design Patterns and Practical Usage
Custom View and Lifecycle
Singleton vs Static and why we use them?
Deep vs Dynamic Linking
Livedata postValue vs set
Livedata vs ObservableField
ViewModelFactory
HashCode and Equals Implementation
Dagger - Component vs SubComponenets
TDD and frameworks - if using , tell the challenges faced
GSON vs Jackson vs Moshi
MultiModule Benfeits
Android Bundle - and Dynamic Feature usage
Proguard vs R8
What is Scoped Storage and how to implement?
Observable vs Completable vs Single
Rx vs Coroutines. Which one you prefer and when?
Difference between MVP and MVVM?
Explain SOLID principles?
Difference between const and val
When is onPause() called without onStop() being called?
Dagger vs Koin?
Any 5 RxJava operatrs. How subscribeOn and observeOn works?
Headless Fragments.
Workmanager, type of requests, methods, minimum interval before a job repeat itself.
Workmanager vs JobScheduler.
Why ConstraintLayout? Tell some properties which I find worth.
How SharedPreferences work internally?
You will be given assignments as your first/last round. They just want to know how you follow the standards. Some ask for UI thing, other ask for architectural patterns. Just check your methods and play well with the logic.That’s all.