For the past year or so, this issue had been a constant companion of mine. The reason for this crash is
“From Android 9 Pie if your service does not call
startForeground within 5 seconds after it has been started with the command
startForegroundService ... then it produces an ANR + Crash.”
No matter what I did including
It didn’t work. Also, the issue couldn’t be reproduced during testing which makes it all the…
On a lazy Saturday, while browsing Medium, I came across an article explaining how to organize credit/debit cards in your digital wallet app. I didn’t read the article but decided to make some of the animations myself (You may find a similar article with same animation. However no code has been copied from the previous article). Below are the animations we will be trying to achieve in this article
To make a searchable RecyclerView we need a RecyclerView (duh) and a SearchView which will accept the user query.
Lets design the layout first. The xml would look like this
<?xml version="1.0" encoding="utf-8"?>
Hilt is the new dependency Injection tool in town. It supports injection in android classes out of the box. In this article we will see how to use Room with Hilt.
Let’s talk a bit about what we are doing then we can get around to the how.
We have a Fragment (MyChannelsFragment) that has a view model (MyChannelsViewModel). The fragment shows data present in view model.
The view model gets the data from a repository (MyChannelRepository). The repository needs to access data from local storage. In this article we will inject a DAO object in our repository that allows…
Dependency Injection is the first step you have to take towards building an app that can be tested. So today we will use Hilt to introduce view model injection into a Fragment.
If you wish to carry along with this article you can checkout the starting code here
First of all we need to add dependencies.
hilt-android-gradle-plugin plugin to your project's root
Then, apply the Gradle plugin and add these dependencies in your
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
In the previous article, we discussed how to set up instrumented tests for our Android app. In this tutorial we will add some new functionality to our app and write unit tests to test that behavior.
You can check out the previous post here
You can check out the beginning code for this article here
In our app we have a simple TextView which shows a string present in app reources.
We will now add a new TextView that will show the number of words shown in the above mentioned simple TextView.
Lets add another TextView to our MainActivity’s layout…
If you are a new developer you must have heard about this dragon called testing that needs slaying. If you have some experience you probably know why it’s so important to add tests to your project as soon as possible. So without getting into why it’s important, let's get straight into the how. In this article, you will be introduced to the basics of writing tests for an Android app that we will develop.
We will start an empty Android project. If you wish to follow along you can check out the code for empty Android project here.