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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:27:57+00:00 2026-05-23T04:27:57+00:00

My application should have some changes after some time (in hours or days) and

  • 0

My application should have some changes after some time (in hours or days) and I would like to test that.

I try to use SystemClock.setCurrentTimeMillis() in my unit test to simulate the change of time/date, but without any luck.

I declared the <uses-permission android:name="android.permission.WRITE_SETTINGS" /> in the manifest of both the application and the test application, that did not change anything.

At this time, I am running those tests on the emulator if that makes any difference…

Edit : With Nick’s help, also requested SET_TIME permission:

<uses-permission android:name="android.permission.SET_TIME" />

But now, the logcat shows :

WARN/PackageManager(59): Not granting permission android.permission.SET_TIME to package com.matthieu.tests (protectionLevel=3 flags=0xbe46)

Another Edit : With dtmilano’s answer…

Added this code (with the right try/catch) in my test:

Runtime.getRuntime().exec("date \"$((10800 + $(date +%s)))\"").waitFor();

When I go on the shell, I can run that command without any problem and I see the time changing in the emulator (I am trying to add 3 hours). When I run my tests with my code, the time does not change at all… ?

What I do on the command line is :

date "$((10800 + $(date +%s)))"

I doubt I need to add the “adb shell” part in the Runtime.exec…

Seems like this is on the right path, but still not able to get it running. And it might also go along what Nick pointed to that it needs to be a system process to be able to change the time… ?

  • 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-05-23T04:27:57+00:00Added an answer on May 23, 2026 at 4:27 am

    http://developer.android.com/reference/android/Manifest.permission.html#SET_TIME

    I searched “android permissions” then on the permissions page, did a find on the word “time”. if you are past api level 8, i would recommend you request that permission.

    Update: based on this link, I do not think it is possible to set the system time from a user space app. For your testing purposes, you may need to manually change the time on the emulator. The only other option I have found requires building and signing your own Android build.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which license should expire after some period of time. I
I have an application that I would like to write an automated test for.
In my application I have use some data ValueCell (something like 20) and I
I have an implementation that just like gmail application, but have met some problem
I have to set some routing rules in my php application, and they should
I have created an SMS application in .NET. I wanted that the application should
I'm creating an intranet asp.net mvc application that everyone in the company should have
I have a web application that should behave differently for internal users than external
I have a console application that should do best effort logging to a database
I have a LAMP (Linux/Apache/MySQL/Php) application that I should release soon. Even if I've

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.