I have a new problem. I am building an Android timer. In the main activity you can choose how long the timer will run. If you have chosen a value a timer activity should appear. My question is simple: How? I don’t know how the timer activity can know how long the timer should run. Can anyone tell me please?
Share
In the intent you use to start the new activity, put an extra that indicates the amount of time with which the Timer should be set. Let’s say you’ve made an intent to start this timer activity called
timeIntentand the amount of time you want the timer to be set for is in a variable calledamountOfTime, they you’d do the following:One your in the timer activity, you can get this amount by calling
getIntent()andgetExtra()like so: