How to Update the Terminal's Time Setting: Difference between revisions

From wizarPOS
No edit summary
No edit summary
Line 1: Line 1:
== Via auto update ==
== Automatic Update via Wi-Fi ==
When you turn on Wi-Fi connection, the date and time will be updated automatically.
* When the Wi-Fi connection is enabled, the date and time will automatically update.
== Via manual ==
== Manual Update ==
From Settings>Date&time, close "Automatic time zone" ,"Automatic date&time", and then set date, time.
* Go to: Settings > Date & Time.
 
* Disable "Automatic time zone" and "Automatic date & time".
== Via API ==
* Manually set the date and time as needed.
Use the android system clock method to change the system time.
== Update via API ==
=== Permissions ===
* Utilize the Android system clock method to change the system time programmatically.
  android.permission.CLOUDPOS_SETTIME
== Required Permissions ==
The application declares the above permission in the manifest.
* To use the API method, include the following permission in your application's manifest: ''''android.permission.CLOUDPOS_SETTIME''''.
 
== Accessing Demo Source ==
=== Demo source===
* To understand the implementation details, please download the [http://ftp.wizarpos.com/advanceSDK/cloudpos/SetTimeDemo.zip complete project demo].
Here are some code snippets:
<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
public static void setDateTime(int year, int month, int day, int hour, int minute) throws IOException, InterruptedException {
public static void setDateTime(int year, int month, int day, int hour, int minute) throws IOException, InterruptedException {
Line 34: Line 33:
     }
     }
</syntaxhighlight>
</syntaxhighlight>
Please download the [http://ftp.wizarpos.com/advanceSDK/cloudpos/SetTimeDemo.zip whole project demo]

Revision as of 19:29, 29 December 2023

Automatic Update via Wi-Fi

  • When the Wi-Fi connection is enabled, the date and time will automatically update.

Manual Update

  • Go to: Settings > Date & Time.
  • Disable "Automatic time zone" and "Automatic date & time".
  • Manually set the date and time as needed.

Update via API

  • Utilize the Android system clock method to change the system time programmatically.

Required Permissions

  • To use the API method, include the following permission in your application's manifest: 'android.permission.CLOUDPOS_SETTIME'.

Accessing Demo Source

public static void setDateTime(int year, int month, int day, int hour, int minute) throws IOException, InterruptedException {
 
        Calendar c = Calendar.getInstance();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, month-1);
        c.set(Calendar.DAY_OF_MONTH, day);
        c.set(Calendar.HOUR_OF_DAY, hour);
        c.set(Calendar.MINUTE, minute);
         
        long when = c.getTimeInMillis();
        if (when / 1000 < Integer.MAX_VALUE) {
            SystemClock.setCurrentTimeMillis(when);
        }
        long now = Calendar.getInstance().getTimeInMillis();
        //Log.d(TAG, "set tm="+when + ", now tm="+now);
 
        if(now - when > 1000)
            throw new IOException("failed to set Date."); 
         
    }