Changing the Internal Android Simulator's Time
Asked Answered
K

3

6

I'm in the process of creating an android app that makes extensive use of the time & date functions in android, including many uses of AlarmManager. For testing though, it's a big pain to change windows' system clock just to test some functionality.

Is there a way to change the clock on he emulator so that it thinks it's on a different day?

Kaiulani answered 3/3, 2011 at 18:24 Comment(2)
I don't see anything "painful" about changing Windows' system clock - I do it for testing my own code. Is it just an annoyance for you, or is it really a labor-intensive process?Tav
@Matt actually there are two pains: 1) having to change it back. 2) watching things like appengine uploads fail because they rely on system clock for authentication. Just seems so much better to localize the change.Kaiulani
M
6

Just do it as you would in a normal handset:

Settings -> Date & Time, then disable Automatic and set the Date and Time

Marie answered 3/3, 2011 at 18:47 Comment(1)
But the time will count further ... Is there no option to freeze the time?Highpressure
H
1

Now I found a solution, which makes it easier to reset the simulator to a specific time without doing this manually every time.

  1. Start a simulator, where you can get root access (simulator without Play Store)
  2. Open Android Adb Command Prompt
  3. Get root access with adb root
  4. Connect to the shell of the emulator with adb -e shell or to a specific emulator with adb -s emulator-5553 shell
  5. Change the date and broadcast it immediately with e.g. date 112509412020.00 ; am broadcast -a android.intent.action.TIME_SET (time format ist MMDDhhmmYYYY.00)
  6. You should see the new time in the simulator and get this on the shell Broadcast completed: result=0

But you still have to call the last command every time to reset it ...

Highpressure answered 25/11, 2020 at 15:24 Comment(0)
C
0

Try this one

  • Settings -> Date & Time > then disable Automatic and set the manual time zone
Carnify answered 3/8, 2024 at 5:23 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.