Skip to content Skip to sidebar Skip to footer

How To Call Another Activity Method In Android Studio?

I have two different activities. The first calls the menu(base) if the user is logged in, but have also the method for display the user information. public class MainActivity exte

Solution 1:

MainActivity has a layout that contains the Views that show the user information. If you are in Base, that Activity has a different layout that doesn't have any Views for showing the user information. You can create a Dialog that shows the user information, or you could add additional Views to Base that would show the user information, or you could rearchitect your application so that you have another Activity which shows the user information and both MainActivity and Base could start that Activity to show the user information.

In any case, you absolutely positively cannot instantiate an Activity like MainActivity using the new keyword! Only Android can instantiate Activity components, because the framework sets up the underlying Context when it does that. It also keeps track of these components and manages the lifecycle callbacks.

Post a Comment for "How To Call Another Activity Method In Android Studio?"