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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:13:25+00:00 2026-05-30T13:13:25+00:00

I need set the date/time from Android programmatically, but I’m not having success! I

  • 0

I need set the date/time from Android programmatically, but I’m not having success!
I have these three sources above:

Source code 1

AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);  
alarm.setTime(1330082817000); 

AndroidManifest:

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

Exception:

Service fatal error : Unable to start activity ComponentInfo{br.com.tdta.service/br.com.tdta.service.Service}: java.lang.SecurityException: setTime: Neither user 10038 nor current process has android.permission.SET_TIME.  
java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.tdta.service/br.com.tdta.service.Service}: java.lang.SecurityException: setTime: Neither user 10038 nor current process has android.permission.SET_TIME.  
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)  
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)  
    at android.app.ActivityThread.access$2300(ActivityThread.java:125)  
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)  
    at android.os.Handler.dispatchMessage(Handler.java:99)  
    at android.os.Looper.loop(Looper.java:123)  
    at android.app.ActivityThread.main(ActivityThread.java:4627)  
    at java.lang.reflect.Method.invokeNative(Native Method)  
    at java.lang.reflect.Method.invoke(Method.java:521)  
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)  
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)  
    at dalvik.system.NativeStart.main(Native Method)  
Caused by: java.lang.SecurityException: setTime: Neither user 10038 nor current process has android.permission.SET_TIME.  
    at android.os.Parcel.readException(Parcel.java:1247)  
    at android.os.Parcel.readException(Parcel.java:1235)  
    at android.app.IAlarmManager$Stub$Proxy.setTime(IAlarmManager.java:237)  
    at android.app.AlarmManager.setTime(AlarmManager.java:289)  
    at br.com.tdta.service.Service.onCreate(Service.java:32)  
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)  
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)  
... 11 more  

====

Source code 2

boolean itsWork = SystemClock.setCurrentTimeMillis(1330082817000);  
System.out.println(itsWork);  

Manifest:

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

itsWork value:

false  

====

Source code 3

SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd.hhmmss");
String data = format.format(new Date(1330082817000));
try {
    Runtime.getRuntime().exec("date -s " + data);
} catch (IOException e) {
}

What am I doing wrong?

Thanks in advance!

  • 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-30T13:13:27+00:00Added an answer on May 30, 2026 at 1:13 pm

    The user application does not have permission to change the device time. Please read the answer by cashbash in the following post for the alternate option.

    Copying here for quick reference:

    According to this thread, user apps cannot set the time, regardless of the permissions we give it. Instead, the best approach is to make the user set the time manually. We will use:

    startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));
    

    Unfortunately, there is no way to link them directly to the time setting (which would save them one more click). By making use of ellapsedRealtime, we can ensure that the user sets the time correctly.

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

Sidebar

Related Questions

I need to check whether set Date and Time automatically is checked or not
I need to construct linq, but day (date time type, i.AllowedTime.AllowedDate.Day), hours and minutes
I have date database entries like the format 2011/01/08 06:10:11, but I need to
I'm using Entity Framework 4.1 Code First. In my entity, I have three date/time
If I have a Date/Time field in Access and I need to find all
I need to set a date and time to 12 midnight regardless of the
I need to set the initial date for the date picker to 03/20/2010 in
So I need to set a DATE variable equal to tomorrow's date and I
I have 3 values that I need to copy from one table to another
I have a varchar column which contains date in following format dd/mm/yyyy I need

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.