Android Pro Tip: How to determine if you’re running in a Firebase Test Lab

In this entry of my Android Pro Tip’s series I’m going to fill you in on an easy, one line piece of code you can use to detect if you’re running in a Firebase Test Lab.

Why would you want to do this?

There are a number of reasons you might need to detect if you’re running inside a Firebase Test Lab, a few of them being:

You get the idea.

So how do you do it?

fun isInTestLab(contentResolver: ContentResolver): Boolean {
return Settings.System.getString(contentResolver,
"firebase.test.lab") == "true"
}

Easy right? Firebase Test Lab returns true when querying for this system settings string, so you can now detect when you’re running inside the test lab inside your code & react accordingly. Simple.

If you have any thoughts or feedback, I’d love to hear what you think in the comments! Also if you have any requests for little hacks or tip’s like this you might be interested let me know & I’ll see what I can do!

I’d love to hear what you think!

Freelance Android Developer since 2012 🎙️Host of CoffeeAndCodingPod.com 🌍 World Tourist ☕ Coffee Addict | robj.me

Freelance Android Developer since 2012 🎙️Host of CoffeeAndCodingPod.com 🌍 World Tourist ☕ Coffee Addict | robj.me