black friday sale

Flat 10% off on the purchase of any two apps or more. Use coupon code - FESTIVAL10

Grab It Now
Check Mobile App
Read now
Start a Project

How to use interface with handler to transfer data between activity and fragment

Save

Interfaces are more flexible than base classes because you can define a single implementation that can implement multiple interfacesInterfaces are better in situations in which you do not have to inherit implementation from a base class.Interfaces are useful when you cannot use class inheritance.

Make an interface like given below where we define multiple methods with different parameters.

Any fragment that should pass data back to its containing activity should declare an interface to handle and pass the data.Then make sure your containing activity implements those interfaces. For example:

Here, ((Your Fragment which implements the interface )).getFileCode(Parameters which you want to be transferred) replace fragment with the container and commit. In your fragment where getFileCode you will get your data in your replace fragment.

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

The support is fast and do everything in their power to make it perfect. If you need customization it's also done right away. I had massive research to select Mobikul and now I'm sure it was the right one.

Igor Souza

Igor Souza

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home