I have read a few articles and answers (including this one) regarding deprecated code, but I'm a bit confused as to how to handle (specifically) the deprecated Fragment
event handler onInflate
.
I have replaced my implementation of
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState)
with
public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState)
If I run my app on a < API23 machine, the replacement code is not called.
If I restore the original deprecated code (so that I now have both methods implemented) then the deprecated code is called, correct functionality returns, but a call is now being made to a deprecated method(?).
And when I run the app on an API23 machine, it appears that BOTH versions of the handler are called.
So the question is, what is happening here? If I am writing code which is supposed to run on both API23 and earlier versions, do I need to implement the deprecated methods as well as the new ones?
And if that's the case, do I need to hunt out and implement other deprecated methods "just in case"? (and, therefore, is there a list of these deprecated methods to "back-code" for?)
UPDATE :
I have now changed from using android.app.Fragment
to android.support.v4.app.Fragment
(i.e. from native fragments to support fragments) and the app is now performing as expected, with the replacement handler code running for all versions, and is stepping through the android source as expected.
But the question remains : WHY?
Why is the 'native' android.app.Fragment
implementation ****ed up? Looking back through earlier questions then this issue was being discussed back in September 2015. So why is it still an issue? And why should there be a difference in the implementation of support and native fragments post API 11?