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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:23:38+00:00 2026-06-10T16:23:38+00:00

Actually i have to perform some technique in which some particular method will be

  • 0

Actually i have to perform some technique in which some particular method will be called after specified time until app destroyed.I Google it and have found services.Using services this work can be performed.I have gone through many Service tutorials so now i can work with services but can anybody tell me how to do this. Should i use services for call particular tack in the background of the activity after specified time?…Thanks….

Edit: I have used following code

public class MyService extends Service {

    int count = 0;

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);
        handler.removeCallbacks(updateTimeTask);
        handler.postDelayed(updateTimeTask, 1000);
        Toast.makeText(this, "Service started................",
                Toast.LENGTH_SHORT).show();
    }

    private Runnable updateTimeTask = new Runnable() {
        public void run() {
            if (count == 50) {
                count = 0;
                Tocken_parser tocken = new Tocken_parser();
                tocken.tockenParser("1");
                Toast.makeText(MyService.this, "coutn===", Toast.LENGTH_SHORT)
                        .show();
                System.out.println("Count ===============");
            }
            count++;
            handler.postDelayed(this, 1000);
        }

    };
    private Handler handler = new Handler();

    @Override
    public void onDestroy() {
        super.onDestroy();
        System.out
                .println("Service destroyed........................................");
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
}

Its working properly but tell me one thing, how to stop services when activity destroyed.

  • 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-10T16:23:40+00:00Added an answer on June 10, 2026 at 4:23 pm

    The answer is YES. Also, the Service that spawned by Activity will be destroyed together; unless, you assign a schedule check on Alarm to wake up your dead Service.

    • 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 method that I want to perform some action asynchronously
I have an app that uses Javascript to perform some calculations and then plot
I have some application, which makes database requests. I guess it doesn't actually matter,
I have some functions in my Javascript code that will perform long operations such
I actually have two questions regarding exception/error handling in the iPhone app that I
I actually have some questions (real childish). 1) If I know that a website
This is a minimal test case of some code that I actually have. It
I have written the following code to perform some simultaneous HTTP posting and file
I have a table and i want some action to be perform on it
I have a class, Action, that has a method called doAction(). This method exists

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.