While profiling my app, I found, that retrieving the NsdManager by using
nsdManager = (NsdManager) getSystemService(Context.NSD_SERVICE); // LEAKS!
is leaking the Activity, while
nsdManager = (NsdManager) getApplicationContext().getSystemService(Context.NSD_SERVICE);
does not. I made a small test app, that does nothing else with the NsdManager than retrieving it using the Activity context, but it's still leaking the activity. Is this a bug? Do I really have to use the application context all the time?
Device: Emulator (Android 11, API 30, x86)