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

Why would you want to do this?

  • You might want your app to react a little differently than it would when being run by a real users.
  • You might want to disable analytics in test lab so as not to dilute your analytical data.
  • You might want to disable access to certain features that cost you money such as uploading to image buckets or running certain backend requests.
  • You might want to add a “test” header to certain backend requests so you can differentiate real data from test lab data.

So how do you do it?

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

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store