Are you able to get the device serial number programmatically for newer devices? What did you try? If I remember correctly this is not possible anymore, however there are methods to get a unique number
I asked ChatGPT for you
ChatGPT was a bit haluzinating again... there is no such extension TaifunDeviceTools or TaifunCryptography available... but there are other extensions available, just search the extensions directory App Inventor Extensions | Pura Vida Apps
Taifun
Excellent — this is a classic “offline activation” flow, and it can be implemented cleanly in App Inventor (or any derivative such as Kodular, Niotron, etc.) even with targetSdkVersion 35, though you’ll need to design around Android’s new privacy limits.
Let’s break it down in a developer-oriented way:
Step 1. Choose your “device ID”
Because of Android’s restrictions, you cannot reliably read the hardware serial (Build.SERIAL) or IMEI anymore (it returns unknown on modern Android versions).
For offline activation, use one of the following:
Android ID (Settings.Secure.ANDROID_ID) — available without permissions; stable per device/user.
Or create your own persistent random UUID stored in TinyDB on first run.
For simplicity:
Use the Device Tools extension (e.g. TaifunDeviceTools) → AndroidId block.
Step 2. Show it to the user
The activation screen has:
Label showing “Your Device ID”
Button “Copy ID” or “Send to Developer”
TextBox for entering activation code
“Activate” button
When pressed:
LabelDeviceID.Text ← DeviceTools.AndroidId
Step 3. Generate the activation code (developer side)
You want a reproducible function that:
Takes the DeviceID as input
Generates a short activation code (that can be validated offline inside the app)
You can do this via a simple hash-based scheme:
Option A: Hash + Secret key
Use a small program (in Python, Java, etc.) with a private secret key known only to you:
import hashlib
def make_activation(device_id):
secret = "MyPrivateSecretKey2025"
data = (device_id + secret).encode()
code = hashlib.sha256(data).hexdigest().upper()
# Shorten for convenience:
return code[:10] # e.g., first 10 chars
So if a user sends ANDROID_ID = a1b2c3d4e5f6g7h8,
you generate and send back DF83A72C5E.
Step 4. Validate in the App
Inside App Inventor, you replicate the same logic (using the same secret key),
then compare the computed code with what the user entered.
App Inventor has a SHA256 block in the Cryptography extension
(e.g. TaifunCryptography):
expected ← SHA256(DeviceID + "MyPrivateSecretKey2025")
expected ← UPPERCASE expected
expected ← segment text expected from 1 to 10
Then:
if enteredCode = expected
then set TinyDB tag "Activated" to true
open main screen
else
show message "Invalid code"
Step 5. Remember activation
On app start:
if TinyDB.GetValue("Activated") = true
then open main screen
else
open ActivationScreen
That’s all.
Summary of the activation logic
Step
User Side (App)
Developer Side
1
Show AndroidId
Receives it
2
—
Run SHA256(AndroidId + secret)
3
User enters activation code
App repeats same formula
4
If match → save flag
—
Security Notes
Keep your secret key private — if someone extracts the .aia they could read it.
To make reverse-engineering harder, obfuscate it (e.g. split into parts, encode).
Android ID may reset after factory reset or on new user profile, so user may need reactivation in that case.
package com.yourcompany.yourextension; // Replace with your package structure
import android.provider.Settings;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContext;
// ... other necessary imports
public class YourExtensionName extends AndroidNonvisibleComponent {
public YourExtensionName(ComponentContext context) {
super(context);
}
/**
* Returns the unique ANDROID_ID for the device.
*/
@SimpleFunction(description = "Returns the unique ANDROID_ID for the device.")
public String GetAndroidId() {
return Settings.Secure.getString(
this.container.$context().getContentResolver(),
Settings.Secure.ANDROID_ID
);
}
}
' =======================================================
' ✅ HMAC-SHA256 → Base64-clean → First 12 uppercase chars
' Secret Key = "APP INVENTOR"
' =======================================================
Option Explicit
'--- دالة رئيسية لاستعمالها في الخلايا ---
Function HMAC_SHA256_12(AndroidID As String, Optional SecretKey As String = "APP INVENTOR") As String
On Error GoTo ErrHandler
Dim hash() As Byte
Dim base64 As String
Dim clean As String
' التأكد من وجود Android ID
If Trim(AndroidID) = "" Then
HMAC_SHA256_12 = "❌ Missing Android ID"
Exit Function
End If
' حساب HMAC-SHA256 باستخدام الدالة المساعدة
hash = ComputeHMAC_SHA256(AndroidID, SecretKey)
' تحويل الناتج إلى Base64
base64 = EncodeBase64(hash)
' تنظيف الرموز = + /
clean = Replace(Replace(Replace(base64, "=", ""), "+", ""), "/", "")
' أخذ أول 12 حرف وتحويلها لحروف كبيرة
HMAC_SHA256_12 = UCase(Left(clean, 12))
Exit Function
ErrHandler:
HMAC_SHA256_12 = "⚠️ Error"
End Function
'--- دالة حساب HMAC-SHA256 باستخدام Windows API ---
Private Function ComputeHMAC_SHA256(ByVal message As String, ByVal key As String) As Byte()
Dim enc As Object, converter As Object
Dim keyBytes() As Byte, msgBytes() As Byte
Dim hmac As Object
Set enc = CreateObject("System.Text.UTF8Encoding")
Set converter = CreateObject("System.Security.Cryptography.HMACSHA256")
keyBytes = enc.GetBytes_4(key)
msgBytes = enc.GetBytes_4(message)
converter.Key = keyBytes
ComputeHMAC_SHA256 = converter.ComputeHash_2(msgBytes)
End Function
'--- دالة تحويل بايتات إلى Base64 ---
Private Function EncodeBase64(bytes() As Byte) As String
Dim xml As Object
Set xml = CreateObject("MSXML2.DOMDocument")
xml.LoadXML "<root />"
xml.DocumentElement.DataType = "bin.base64"
xml.DocumentElement.nodeTypedValue = bytes
EncodeBase64 = xml.DocumentElement.Text
Set xml = Nothing
End Function