Created
March 18, 2011 15:20
-
-
Save paulononaka/876246 to your computer and use it in GitHub Desktop.
Setting a specific date/time in Android.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void settingDeviceDateTime(Date date) { | |
Calendar c = Calendar.getInstance(); | |
c.setTime(date); | |
SystemClock.setCurrentTimeMillis(c.getTimeInMillis()); | |
Log.d(TAG, "Setting time to: " + new SimpleDateFormat("MM/dd/yyyy hh:mm:ss").format(c.getTime())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This requires that you use the same certificate of system in your application or you must embed your application in the Android compilation. In both alternatives, put a attribute in AndroidManifest.xml -> android:sharedUserId="android.uid.system"