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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:24:46+00:00 2026-06-15T06:24:46+00:00

Basically I have created an app into which the user enters a number (in

  • 0

Basically I have created an app into which the user enters a number (in seconds). They then click a button and a service is created which runs a countdown starting at the number of seconds entered. However in my service I reference variables such as:

public EditText text = (EditText)findViewById(R.id.editText1);
int Time = Integer.parseInt(text.getText().toString());

This ‘breaks’ the service as it is static and can’t reference findViewById.
I have tried for hours to work around this but I have no clue, any help much appreciated!

  • 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-15T06:24:47+00:00Added an answer on June 15, 2026 at 6:24 am

    Why does the Service have to be static? A Service should be either started/stopped or bound/unbound (or a combination of the two). You shouldn’t have to create a static Android Service.

    Put this code into your Activity and not the Service…

    public EditText text = (EditText)findViewById(R.id.editText1);
    int time = Integer.parseInt(text.getText().toString());
    

    …then just pass the time to the Service in the Intent you use to start it…

    Intent i = new Intent(this, MyService.class);
    i.putExtra("the_time", time);
    startService(i);
    

    Then in the Service onStartCommand(...) method use…

    int time = intent.getIntExtra("the_time", 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which basically allows an admin user to create manager user
I am currently making an app that will have multiple timers, which are basically
I have a 3-tier .NET service app, which follows the standard approach: Frontend ->
I have an android app, which is basically an exam simulator, it will come
Currently i have an iPhone app for which is basically a city guide. It
I have created following thing in android using android compatibility support package Basically i
Basically, I have created a custom control that uses an UpdatePanel, and as I
Basically, I am using Wireshark looking at captures that have been created previously. How
Basically, I have a model where I've created a superclass that many other classes
I'm trying to create a responsive gui, which basically means that I have an

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.