I have a class NavActivity
public class NavActivity extends Activity implements OnItemLongClickListener {
....
}
In a function from another class, I have the following code:
LocalActivityManager activityManager = this.getLocalActivityManager();
Window window = activityManager.startActivity(tag, intent);
final View view = window.getDecorView();
Context decorContext = view.getContext();
NavActivity nextActivity;
nextActivity = (NavActivity)decorContext;
In previous versions of Android, everything has worked well. But in Android 7.0. it stops at this line and shows the following error:
Caused by: java.lang.ClassCastException: com.android.internal.policy.DecorContext cannot be cast to xxxxx.nav.NavActivity
Don't understand why casting from DecorContext into Activity does not work anymore in Android 7.0.