![]() You can find this tiny library on github and is available on maven central. Hence you should avoid to use that dependency in your release. Please note that com.hannesdorfmann:debugoverlay:0.2.0 will add _ALERT_WINDOW permission to your apk. The debugoverlay-noop adds 1 class and 3 methods to your release dex file, which from my point of view is an acceptable compromise. I use gralde build types to include the debugoverlay dependency that do display the debug overlay window in debug builds and use the other debugoverlay-noop dependency for release builds. ReleaseCompile ( 'com.hannesdorfmann:debugoverlay-noop:0.2.0' ) // Does nothing Yes, services can have Views:ĭebugCompile ( 'com.hannesdorfmann:debugoverlay:0.2.0' ) // Starts the service and displays the overlay In a nutshell: Implement your own android Service and use the WindowManager to add a View. I’m sure there are plenty tutorials and blog post out there describing how to implement something like that. I guess you have already heard or already used facebook’s chat heads. How to implement such a window? It’s easier than you might have thought before. Why an independent window? Because I want avoid side effects on my production code. What I really want is having an independent window just for displaying tracking information in a logcat alike fashion, something like this: The problem with that approach is that this leads to fragile code. An alternative could be to add a TextView dynamically on each Activity and Fragment’s root layout. So how could we display the tracking information? The simplest way is to display a Toast, but that doesn’t work well when navigating fast in the app like swiping in a ViewPager. Hence he need a comfortable way to get displayed this information directly in the app. As already said this external staff is not a developer. However, there is a lot of money depending on the correctness of the tracking (advertisement contracts are negated on the reach of the app) and therefore an external staff has to verify manually that the tracking works correctly. Obviously, we can and should write unit tests for that (Robolectric powered unit tests could do that job much faster as instrumentation tests). In my concrete use case I was looking for a way to display tracking information on screen to allow external staff (not developers) to validate that the app was tracking the right information as the string to be tracked is computed dynamically for each screen (plenty of parameters and conditions). But what if we have to provide app internal logs to non developers? Can they access logcat? Do they have to install android studio and enable developer options on their android device? Wouldn’t it be nice if non developers could just see these logging information directly in the app somehow? Usually we as developers would log app internal things by using logcat Log.d(). Hence I have written my own tiny library called DebugOverlay to do this job. ![]() I haven’t found a library that fit my needs. Lately I was looking for a way to display some app internal information to an external staff that is not a developer.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |