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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:07:35+00:00 2026-05-26T10:07:35+00:00

I found some info about how to access the context from the subclass and

  • 0

I found some info about how to access the context from the subclass and also some info about

runOnUiThread(new Runnable() {
  public void run() {
    // Do something
  }
});

But in my case it does not work. The application is still running, but the activity is maybe already destroyed. The first (main) activity is the parent activity of the one where my TimerTask is created. My code:

TimerTask tt = new TimerTask() {
  @Override
  public void run() {
    // do something (cut)

    // and at the end show info
    getParent().runOnUiThread(new Runnable() {
      @Override
      public void run() {
        Toast.makeText(getParent(),
                  getResources().getString(R.string.st_toast_msg_stopped),
                  Toast.LENGTH_LONG).show();
      }
    });
  }
};
curTimer.schedule(tt, millisecondsUntilStop);

There is no error/ exception at log. But the toasted message is not shown. 🙁

Now I have no Idea what I can else do/ try. I hope someone of you can help me.

P.S.: Maybe I use the wrong context? But I tried also some other context like the Context of the current activity, the ApplicationContext, … .

  • 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-05-26T10:07:36+00:00Added an answer on May 26, 2026 at 10:07 am

    Well you are using the wrong context here that is getParent(). Instead of using getParent() try to use the current_Activity.this like this,

    TimerTask tt = new TimerTask() {
      @Override
      public void run() {
        // do something (cut)
    
        // and at the end show info
        Activity_name.this.runOnUiThread(new Runnable() {
          @Override
          public void run() {
            Toast.makeText(Activity_name.this,
                      getResources().getString(R.string.st_toast_msg_stopped),
                      Toast.LENGTH_LONG).show();
          }
        });
      }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i googled a lot and found out some info about the band object from
I have been checking out some info about 64-bit driver development; I found that
I have found some info on the subject ( like this link) , but
I found some mapkit code on the internet that looks like this: - (void)recenterMap
I found some information about this on Scott Hanselmans Blog Does anybody exactly know
I'm trying to find some info about apps I find using shell's top command.
I've found this information on SO about how to enumerate the sound device info
I'm looking for the algorithm (C#) or some info about how detect the edge
Found some old code, circa VS 2003. Now I have just VS 2008 (SP1)
I found some code in a project which looks like that : int main(int

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.