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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:03:07+00:00 2026-05-27T22:03:07+00:00

I have application with a Service . This service starts worker Thread , and

  • 0

I have application with a Service. This service starts worker Thread, and this thread needs a pointer to an instance of Service (it calls some methods of this service).

Now i just pass this pointer from Service‘s onCreate() method to my own Runnable constructor, but it works correctly until i close my app. When app is restarted, something becomes really wrong with pointers. I still can’t figure out what especially is wrong, but it seems like pointer to my instance of Service is a pointer to strange another instance of Service, and pointer to my Runnable is wrong too.

If i kill my app, then next time it works correctly, but after restart the same issues is taking place.

I suspect that i can’t pass this pointer from onCreate() method of Service, but then, how can i get pointer to instance of my Service from the thread that starts from onCreate() method?

UPDATE: I just figured out that i have exactly the same singleton issue. The Runnable was a singleton. But i still can’t find any good solution except not to use singletons in Android at all. Maybe, any suggestions?

  • 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-27T22:03:08+00:00Added an answer on May 27, 2026 at 10:03 pm

    this thread needs a pointer to an instance of Service (it calls some methods of this service).

    There are no pointers in Java. The Java equivalent would be “object reference”.

    until i close my app

    There is no such concept as “closing” an “app” in Android.

    I still can’t figure out what especially is wrong, but it seems like pointer to my instance of Service is a pointer to strange another instance of Service, and pointer to my Runnable is wrong too.

    That is eminently possible, if you stopped the original Service and leaked the thread, then started up the Service again. You may well have wound up with two threads, one holding a defunct copy of your Service.

    how can i get pointer to instance of my Service from the thread that starts from onCreate() method?

    That is not your problem. Your problem, whatever it is, lies elsewhere.

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

Sidebar

Related Questions

I have a WCF service application and in this app I am doing calls
I have developed a Web service using WCF Service Application. This service application is
I have a Web Service and an Android application that uses this web service.
Greetings, I have a wcf service that exposes functionality to my wpf application. This
I have VB application that requires visual service pack 6 to run , now
I have client application that uses WCF service to insert some data to backend
I have a windows service doing some repetitive work (wcf calls) after logging programmaticaly
I am working on an application that runs a service. This service starts automatically
I have just written a program to run as a Windows Service Application, GasMeterMonitoring;
I have a service application that on startup reads an XML file and starts

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.