Change the Android phone number to the date the button was pressed on the Android application

I am trying some things with android as I am learning Android development, now I have a script here.

  • I want to change the date of the Android phone system in my application ( which I would like to know is this doable? )

Layout below

layout

Now I want, when the user clicks the button, the date should increase, say, 20 days how can I do this.

I can not start ... please help

+6
source share
4 answers

As I said, this is not possible. You need SET_TIME permission, and this permission is provided by the system only for applications that are in the Android system image. If you can get this privilege, you can easily change it using the AlarmManager. SystemClock.setCurrentTimeMillis write file / dev / allarm

 adb shell ls -l /dev/alarm crw-rw-r-- system radio 10, 46 2013-06-12 10:46 alarm 
  • c remains for Character special file (stored in /dev).
  • the system is the owner of the file
  • radio is a group

the system and the radio have read and write permissions (rw-, tree bits, int 6 value), the rest have only read permission (r, int 4 value). Thus, the resolution of the file is 664 . If you can get the root user (running su ), you can change the resolution of this file and write a new value in it. An error report was completed to ask Google to allow applications to programmatically change the date of the mobile connection, but it was rejected. Here is the link

+7
source

On Android, the only way for an application to have write access to & date is to get SET_TIME permission, which is only possible for "applications that are in the image of an Android system or signed with the same certificate as the application that announced the permission." (see signatureOrSystem security level ).

The only way for your application to achieve this level of protection is to run it on the root device or create and sign your own Android movie.

If this is your case, you can easily use AlarmManager or just Calendar .

Good luck

+4
source

Normal user applications do not have permission to change the deviceโ€™s time. Read the cashbash response in the next post for an alternative.

0
source

Unfortunately, the black bar is right; Android allows us to do many cool things, but program time with program time is not one of them.

Since I see that you are looking for more reliable / official sources, I suggest you check this open ticket with Google , which offers this open problem - it should work, but it is not, and it seems that Google is not going to fix it in soon. Its essence is that the level of protection SET_TIME is set higher than it should be. (for more information on permissions see here )

Although this is not exactly the same as changing the time programmatically, you can still force the user to change the system time for you if for some reason you need the system time to change. This thread will explain how to do this if you want to go this route.

Hope this was helpful information!

0
source

Source: https://habr.com/ru/post/946614/


All Articles