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

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -