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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:30:20+00:00 2026-06-10T05:30:20+00:00

In terms of life cycle, when I call stopService(intent), does the service’s onDestroy() get

  • 0

In terms of life cycle, when I call stopService(intent), does the service’s onDestroy() get called right away? I am asking because I have problem getting the onDestroy() called to kill this thread the service generates.

Thanks in advance!

button.setOnClickListener(new OnClickListener(){
        public void onClick(View v){

            Log.d(Tag, "in button's onClick");


            Log.d(Tag, field.getText().toString());
            String busNo = field.getText().toString();
            field.setText("");
            field.setAdapter(clearAdapter);
            String url = makeURL(busNo);
            Log.d(Tag, "after makeURL(), url is now "+url);
            Intent intent = new Intent(JSoupTest9Activity.this, ServiceTest.class);
            Log.d(Tag, "intent created...");
            intent.putExtra("URL", url);
            Log.d(Tag, "intent's extra put");
            Log.d(Tag, "stopping intent service");
            stopService(intent);
            Log.d(Tag, "starting intent service");

            startService(intent);
            Log.d(Tag, "service started");

            //pendingIntent = PendingIntent.getService(JSoupTest8Activity.this, 0, intent,  0);
            //alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 30*1000, pendingIntent);

        }
    });

As you can see, I called stopService() to kill any previous services(query threads) to start a new service(new query thread).

  • 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-10T05:30:22+00:00Added an answer on June 10, 2026 at 5:30 am

    It will not be called inmediatelly only by statically calliong stopService. As pointed in the activity’s lifecycle diagram, it will be destroyed if the vm needs resources

    When I am in doubt, I simply use the log tool and check their output on LogCat. If you override OnDestroy method like this:

    protected void onDestroy() {
    Log.d("event","onDestroy was Called!");
    super.onDestroy();
    }
    

    You can verify yourself when it was called.

    And if you want to destroy one of your activities in Background you may use an activity manager:

    ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    activityManager.killBackgroundProcesses("<packagename>");
    

    If it’s not within your app you of course need to set permissions on the manifest. With my limited experience, I have not found a time where I needed to destroy any process; but I do have found much documentation telling me not to, for example

    Checking further, I think this quesiton was covered already

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

Sidebar

Related Questions

Can you please explain the life-cycle of an XAML file in terms of compiling?
In terms of SQL terminology, does HEAP stands for a table that has Non-Clustered
In terms of performance and efficiency, is it better to use lots of small
In terms of actual low level atomic instructions and memory fences (I assume they're
What is ISCL in terms of TCP
What do the terms CPU bound and I/O bound mean?
It seems that licensing terms would prevent us from using Google Maps API in
Reading on Wikipedia: The terms high-level and low-level are inherently relative. Some decades ago,
In general terms and pseudo-code, what would be the best way to have a
I want to show terms and condition note on my website. I dont want

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.