How to set time in Dragonboard programmatically in Android


I have been trying to set time programmatically in my Dragonboard in Android 5.1.1. I have followed many StackOverflow solutions which seems working in android phones but not in dragonboard.
I have followed these

  1. How to set time to device programmatically

  2. Programmatically set System Time

  3. Set Android’s date/time programmatically

I have also set alarm permission like this
chmod 666 /dev/alarm
chmod 777 /dev/alarm

I am getting following error
java.lang.SecurityException: setTime: Neither user 10094 nor current process has android.permission.SET_TIME

Have anybody done it earlier?


How do you build your app?

AFAIU, you need to have the following in your manifest:

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


Hi @Loic ,
I have added that in manifest file but it did not work. And I have also tried to put app in System/app folder but it not setting time from there too, it is simply opening time setting window in screen GUI.


Does no body got it successfully working? If yes, Please share some solution.


Hi @Loic,
Please see here

I had done exactly the same as you suggested but I am getting the following error

  java.lang.SecurityException: setTime: Neither user 10098 nor current process has android.permission.SET_TIME.

I had also given chmod 777 persmission to /dev/alarm with root permission. Would you download GitHub project and see if it is working in your case.

Android OS details are as follows


Your line 6 and 7 permission lines are WRONG. It needs to be <uses-permission android:name="whatever" />

What you are doing is trying to DECLARE a new permission for other applications to use, and they conflict with existing permissions so obviously won’t be accepted – if you watch your logcat, it probably gives out a nice error on installation.


Hi @doitright,
I had changed it to following

<!--Allows applications to set the system time -->
<uses-permission  android:name="android.permission.SET_TIME" />
<uses-permission  android:name="android.permission.SET_TIME_ZONE" />

and now I am getting following warning in Manifest file.

permission is only granted to system apps

Although, it compiled and installed the application but terminated immediately with following logcat

D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.timesetting, PID: 7887
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.timesetting/com.example.timesetting.MainActivity}: java.lang.SecurityException: setTime: Neither user 10099 nor current process has android.permission.SET_TIME.
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(
 Caused by: java.lang.SecurityException: setTime: Neither user 10099 nor current process has android.permission.SET_TIME.
    at android.os.Parcel.readException(
    at android.os.Parcel.readException(
    at com.example.timesetting.MainActivity.onCreate(
    at android.os.Handler.dispatchMessage( 
    at android.os.Looper.loop( 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke( 
I/Process: Sending signal. PID: 7887 SIG: 9
Application terminated.

Please check updated code at github.


Are you just installing it as a regular user application? You can’t set time from a user application. Imagine if you installed an application on your phone and it decided to change the system time… that would be very bad since it has the potential to screw up meeting notifications, alarm clocks, etc. I thought that you would understand this, since all of the reference links you have in your original post said this clearly.

Your only option for this, if it must be done, is to install the application AS a system application, which means copy the apk file into /system/app/ and reboot.


Hi @doitright,
Yes, I do understand it. I had generated .apk then pushed into /system/app folder thereafter I had rebooted it but It did not work. I had tried almost all available options. Can you please check in your board and let me know if it is working there.


Did you uninstall it from the user partition first? Or factory reset? And check the logcat to see what it says upon installation.

Note: I do NOT work for Linaro. I don’t have easy access to a db410c for testing/debugging other user’s issues, so I won’t be testing or debugging your software for you. Frankly, I wouldn’t expect anyone at Linaro to do that either, since your issue really is a general Android thing rather than a db410c specific thing.

What I would ask you, however, is for an explanation as to WHY you are trying to set the system time from an Android application. There is probably a better way to accomplish what you are trying to do.


Hi @doitright ,
I do not have internet support in DB410c so I am sending timestamp via BLE at startup to set time so that in future DB410c should give right timestamp as per current date. Otherwise, via internet it was automatically updating the time.

I will try to figure it out. Although, I had tried almost all possible way, I might have missed something somewhere.


Have you considered putting an RTC on it?


Hi @doitright ,
This is how, currently, I have made it working temporarily. RTC had added extra cost and a little complexity that’s why I am not preferring to add that.


Ok, so I’m understanding then that you are trying to manufacture a product that includes a db410c, and that it is connecting up to something else via BTLE, and that other thing has rtc or network. Is that correct?


Yes. You have got it @doitright. Although, end product would not include db410c. I already have working custom board with Snapdragon. It is 100% portable from db410c to custom board.


Well heck, if you’re using a custom board, then you don’t need to add an external RTC – it already has one, you just need to add a battery for it.


@doitright exactly but the problem is currently don’t have RTC/battery support in the current version.


Don’t tell me that you’ve gone ahead and ordered a bulk print of your board before you have your product fully shaken down… Just add the changes to the design so that next run has rtc. For this run, use external rtc and call it good. There is no sense in implementing weird hacks that you will have to support long term, I’m sure it will end up costing a lot more to do that in the long run.

Anyhow, if you really want to do it without using RTC, then there are a number of options;

  1. Get that application running properly as a system application,
  2. Start a daemon from an init script that waits for connection from your application (i.e., bypass the system security),
  3. network over bluetooth to use NTP.

Can you provide more details about the bluetooth device you are connecting to?


@doitright Nah, just got few boards for internal testing. Next rev would have RTC and battery support on board but that is at least 2 months away and I can’t wait till then. Therefore, I am trying to make it working so that other things should not stuck because of that.

It is connecting with the mobile device over the BLE.


Phone should be able to do Bluetooth classic, which makes it trivial to set up a pan network for NTP.

You can even automate it.

On your phone run this:

On the dragonboard run this:

Note that it was built for Android 9, so it would probably need some work to make it work with 5.1.

As soon as the pan network connects, it will update the time over NTP.