In Android 7 (Nougat), Android introduced a multi-window function that allows you to immediately open 2 actions on the screen (whether itβs your actions or 2 different ones). To do this, they introduced a new class called DecorContext , which will be used by DecorView . DecorContext is a (quote) "Context for decor views that can be visited using the pure context of the application and are not activity-dependent, but still provide some of the features that Activity has, such as themes, resource-based activity, etc. d. ". This means that DecorView no longer knows which Activity it belongs to, only to which Application . Therefore, based on Nougat, it is impossible to get an Activity only from DecorView .
Not sure if it still applies to you, but you can do this:
Activity a = (Activity) decorView.findViewById(android.R.id.content).getContext();
source share