I have two activities with fragment1 inside activity1 and fragment2 inside activity2
fragment1 and fragment2 extend from Fragment activity1 and activity2 extend from AppCompatActivity
i want to send String value from fragment1 to fragment2 without getting Null value. I hope you understand the problem. thanks
Best way to achieve this is using singleton pattern, you can use it for fragment-fragment, fragment-activity communication.
See this answer , it explained with code there and in a very meaningful way. but what i preferred from my experience is you should user EventBus if you want to handle bigger projects with many fragments and larger dependencies, connections and data flows within and between fragments and activities.
The basic communication can be done as per suggested in Developer documentation here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.