开发者

Changing the Internal Android Simulator's Time

开发者 https://www.devze.com 2023-02-14 11:51 出处:网络
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 b

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?


Just do it as you would in a normal handset:

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


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 ...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号