Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8393449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:47:24+00:00 2026-06-09T19:47:24+00:00

OK, I have a login class like the snippet below public class LoginClass {

  • 0

OK, I have a login class like the snippet below

public class LoginClass {

    public void login() {
        login.authorize(username,password); 
            //run activity specific code here
    }

}

This class is quite generic, but depending on which activity calls LoginClass.login(), I would like different actions to be performed.

I’ve seen some implementation where a function is passed into the class and this function is then run on completion. Can anyone give me a brief example on how to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:47:26+00:00Added an answer on June 9, 2026 at 7:47 pm

    Functions are not first class objects in Java as seen on Android – you cannot pass a function. The ideology of Java calls for deriving from your generic class (possibly anonymously) when it needs to be specialized. Like this:

    class MyActivity
    {
    
        void onCreate()
        {
            MyButton.addOnClickListener(
                new LoginClass()
                {
                    //Just like LoginClass, but with one method overridden
                    public void login()
                    {
                        super.login(); //Call the base
                        ThenSomethingElse();
                    }
                });
        }
    }
    

    Alternatively, you can create hooks in the login class – functions that are called whenever custom action is needed – and override those in the activity. Such is the Java way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Login.php form like this: class Form_Login extends Zend_Form { public function init()
I have a Login Class which has a function: isCorrect() that takes username and
Hi every one I have these classe @Entity @Table(name = login, uniqueConstraints={@UniqueConstraint(columnNames={username_fk})}) public class
I'm perplexed by this. I have a login action that looks like this: public
I have created a form like this: class Form_Login extends Zend_Form { public function
I have a 'Login' domain object: public class Login extends AuditEntity { private static
I have a package with logic classes(like CheckAuthenticationDataLogic.java, GetVocabulariesLogic.java). And another class - ApiService.java
I've been looking at using session_regenerate_id in a login class which I have been
I have an Employee class object that I am calling from my Login.aspx page's
I have login- and game-layout in my activity. I would use AndroidAnnotations in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.