👉 How can I detect if a user’s phone time is set manually (not automatic) in Kodular or Android apps?

Hi everyone :waving_hand:
I want to detect when a user has manually changed the date or time on their phone.
Some users in my app try to cheat the daily reward system by turning off “Automatic date & time” and setting the time manually.

What I want to achieve:

  • Detect if the phone’s time is not synced automatically (manual mode).
  • Show a warning like: “Please enable Automatic date & time to continue.”
  • Optionally open the settings screen automatically.

My questions:

  1. Is there any way in Kodular (or via an extension) to check if “Automatic date & time” is OFF?
  2. If not possible directly, can I detect this indirectly — like by comparing server time (Firebase or WorldTimeAPI) with device time?
  3. How can I block rewards or show a popup if the difference between server and device time is large (manual change detected)?
  4. Any example Kodular blocks or logic flow would really help :folded_hands:

Thanks for your help!
kodular firebase android #WorldTimeAPI #AntiCheat #DailyReward

Hie,

I don’t know if this will work but it’s worth to give a try

I read about this last year

If you send data like

When Reward Claimed

  1. Call Firebase StoreValue

Tag: Users//lastClaim

Value: { “.sv”: “timestamp” }

If your value .sv: with time claimed it keeps something

Edit: give me some minutes I will try it myself and give you it’s results

Here is an answer from ChatGPT
Taifun


Good question — this is a very common issue for apps that rely on daily rewards or time-based logic.
Let’s break it down for Kodular / App Inventor environments (which run as standard Android apps).


:white_check_mark: 1. Detect if “Automatic date & time” is OFF

Unfortunately, App Inventor / Kodular does not have a built-in block to check whether the system’s “Automatic date & time” (network-provided time) is enabled.

However, this information can be read on Android using the following Java APIs:

Settings.Global.getInt(getContentResolver(), Settings.Global.AUTO_TIME, 0)
  • Returns 1 → Automatic date & time ON
  • Returns 0 → Automatic date & time OFF

But — you can’t call that directly from App Inventor unless you use an extension.


:wrench: 2. Using an Extension

To access that Android setting, you’d need a custom extension (AIX) that calls this Java API.

Option A: Use an existing extension (if available)

There is no official extension that exposes this setting yet, but some community extensions can read global settings.

Try searching for:

  • “Device Settings Extension”
  • “System Settings Extension”
  • “Get System Property Extension”

For example, developers like Atom Developer or Sunny Gupta (Sunny) often publish such tools.

If none exists, you can create one easily with a short Java snippet:

@SimpleFunction
public boolean IsAutomaticTimeEnabled() {
    try {
        return Settings.Global.getInt(context.getContentResolver(), Settings.Global.AUTO_TIME) == 1;
    } catch (Settings.SettingNotFoundException e) {
        return false;
    }
}

:gear: 3. Open the Settings screen

You can open the date/time settings screen using an Activity Starter:

Property Value
Action android.settings.DATE_SETTINGS

That will open the Android date & time settings screen where the user can turn Automatic date & time back ON.


:light_bulb: 4. Workaround if you can’t check AUTO_TIME

If you cannot or don’t want to use an extension, there are still some practical checks you can do:

  • Compare device time with an internet server time (e.g., via a small API call like https://worldtimeapi.org/api/ip).
    → If the difference is large (say >2 minutes), assume the user changed time manually.

This method works entirely in App Inventor, using the Web component.


:white_check_mark: Summary

Goal How to do it
Detect if automatic time is off Needs small custom extension (uses Settings.Global.AUTO_TIME)
Open date & time settings Use Activity Starter → android.settings.DATE_SETTINGS
Detect time cheating without extension Compare device time to online time API

If you’d like, I can provide the Java source code and full AIX extension template for IsAutomaticTimeEnabled() — would you like me to generate that?

package com.yourname.autotimedetector;

import android.provider.Settings;
import android.content.Context;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;

@DesignerComponent(
    version = 1,
    description = "Detects if Automatic Date & Time is enabled on the device.",
    category = ComponentCategory.EXTENSION,
    nonVisible = true,
    iconName = "aiwebres/icon.png"
)
@SimpleObject(external = true)
public class AutoTimeDetector extends AndroidNonvisibleComponent {

    private Context context;

    public AutoTimeDetector(ComponentContainer container) {
        super(container.$form());
        context = container.$context();
    }

    @SimpleFunction(description = "Returns true if 'Automatic Date & Time' is enabled in system settings.")
    public boolean IsAutomaticTimeEnabled() {
        try {
            int autoTime = Settings.Global.getInt(context.getContentResolver(), Settings.Global.AUTO_TIME);
            return autoTime == 1;
        } catch (Settings.SettingNotFoundException e) {
            return false;
        }
    }

    @SimpleFunction(description = "Returns true if 'Automatic Time Zone' is enabled in system settings.")
    public boolean IsAutomaticTimeZoneEnabled() {
        try {
            int autoZone = Settings.Global.getInt(context.getContentResolver(), Settings.Global.AUTO_TIME_ZONE);
            return autoZone == 1;
        } catch (Settings.SettingNotFoundException e) {
            return false;
        }
    }
}

Hi,

Another method could be using a shell command.
Unfortunately, Kodular’s shell component doesn’t work properly, but by using KIO4_Terminal you can run:

curl -s --head http://google.com | grep “^Date:” | awk ‘{print $6}’

This command returns the header of Google’s page,

HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-4VmL4MJ7OA8WnXjWRsiITA' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
Date: Wed, 29 Oct 2025 15:32:36 GMT
Expires: Fri, 28 Nov 2025 15:32:36 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN

which contains various information including the Date with GMT time and this specific command will extract only the time.

1 Like