android - How to fetch fragment manager without extending the Activity -
i using libraries build cards, java extends library class have requirement use fragmentmanager in java class tried using inner class getting null pointer exception
if have activity
reference: activity.getfragmentmanager()
if have fragment
reference: fragment.getfragmentmanager()
they both public
methods, you'll need reference either activity or fragment.
also, , though don't recommend it, if have view
reference, view.getcontext()
method likely activity
, might able cast , fragmentmanager
way. potentially dangerous, , stop working @ moment if android's implementations change, should know you're doing. passing activity/fragment reference way go.
Comments
Post a Comment