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 8865493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:31:28+00:00 2026-06-14T16:31:28+00:00

I am trying to end an never ending circle. I need to call a

  • 0

I am trying to end an never ending circle. I need to call a void that is not static from another class. The reason that I do not make it static is that some things are very hard to make static. (Everything inside a static void needs to be static).

I am trapped in a circle where I need to call a non static void from another class. I can not make it static because it some code do not like to be passed.

Till now I solved it sort of by a handler:

public static void change(){
//This is called to change a boolean
start=true;}

private void startDone(){
int timeBetweenChecks = 50;
final Handler h = new Handler();
h.postDelayed(new Runnable(){
    public void run(){
        if (start==false){
           startDone();

        } else{  
            //Do something          
        }          
        }
    }
}, timeBetweenChecks);

};

The problem with this is that I have to run a handler that is checking if something has changed pretty often(In my case).

Is there any way of calling the non static startDone() directly?

  • 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-14T16:31:29+00:00Added an answer on June 14, 2026 at 4:31 pm

    The answer to your question is: No, you cannot call a non-static method from a static method without an instance of the class containing the non-static method.

    To solve your problem: maybe the best way would be to broadcast an intent from change().

    Something like:

    public static void change(Context c){
        start=true;
        c.sendBroadcast(new Intent("CHANGE_HAS_BEEN_CALLED"));
    }
    

    Then in the non-static code of your activity you can register a receiver like this:

    IntentFilter filter = new IntentFilter();
    filter.addAction("CHANGE_HAS_BEEN_CALLED");
    registerReceiver(new BroadcastReceiver() {
        @Override public void onReceive(Context context, Intent intent) {
           if (start==false){
               startDone();
    
            } else{  
                //Do something          
            }
        }
    }, filter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a never-ending problem with trying to call a stored procedure from a
I'm trying to build a navigation window that never appears to end - each
I'm trying to parse a never-ending xml stream that looks like this: <outer> <foo>footext</foo>
Trying to write a javascript bookmarklet to jump from a front end link into
I am trying to check while not end of file in c programming. Can
I'm trying to match expressions that start with PRE and end with PRE. I'm
I am trying to use the call function from the Python library inside a
I'm trying to configure Ehcache (version 2.5) such that it never forgets items. I'm
I am trying to attempt to call back a value from a function, however,
I'm trying to check that dates entered by end users are in the YYYY-MM-DD.

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.