Search code examples
javaandroidprofiles

Two types of profiles in one Android app


I really need to create two types of profiles in my application, for example for people who need help and for people who can help. The thing is that I'm not experienced in programming enough, so I don't understand even how to start coding this. Depending on the type of account, people will have different menus and different opportunities in the app. Should I create 2 separated activies for them every time or what should I do at all? I'd be extremely grateful if you helped me.


Solution

  • It depends on what are the differences. Case scenarios are the following

    1. Use a condition, if user have attribute helper == true then show something, else hide something
    2. Create a base class with the shared attributes and two classes that will inherit it. You have to have both profiles in 2 sets of data, then the base activity or fragment has the common between those and the children that inherit from it add their own special features. Here is a SO answer covering the inheritance I'm referring
    3. It could be you don't need 2 profiles, maybe the actions that user do are different, if so, then create different data whenever those actions are triggered by any user. Any user can see both buttons: "Ask for help", "Help Someone". Depends on what button is pressed the logic is triggered.