Android Question Kiosk - settings.txt

Nikan99

Member
Hello!
I have made an app and I want to disable navigation and status bar of the device. I have seen kiosk app of Erel and I have test it and works fine in my device. I have followed exactly what is written to add it to my app but it does not work. I have noticed that I missed the file "settings.txt. Do you have any idea how to claim it to put it in my app? Or how to create it to my app?

Best regards,
Nikos
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Settings.txt is automatically created when the lock state is written.

B4X:
Sub WriteLockState(locked As Boolean)
    File.WriteMap(File.DirInternal, "settings.txt", CreateMap("locked": locked))
End Sub

You don't really need this. You need to use the lock method

B4X:
Sub btnLock_Click  'could be renaned to just Lock
    GetManager.RunMethod("setLockTaskPackages", Array(GetAdminComponent, Array As String(Application.PackageName)))
    GetContext.RunMethod("startLockTask", Null)
    WriteLockState(True) 'this line is unncessesary
End Sub

Sub btnUnlock_Click ' Could be renamed unlock'
    GetContext.RunMethod("stopLockTask", Null)
    WriteLockState(False) ' This line is not necessary
End Sub
 
Upvote 0

Nikan99

Member
Settings.txt is automatically created when the lock state is written.

B4X:
Sub WriteLockState(locked As Boolean)
    File.WriteMap(File.DirInternal, "settings.txt", CreateMap("locked": locked))
End Sub

You don't really need this. You need to use the lock method

B4X:
Sub btnLock_Click  'could be renaned to just Lock
    GetManager.RunMethod("setLockTaskPackages", Array(GetAdminComponent, Array As String(Application.PackageName)))
    GetContext.RunMethod("startLockTask", Null)
    WriteLockState(True) 'this line is unncessesary
End Sub

Sub btnUnlock_Click ' Could be renamed unlock'
    GetContext.RunMethod("stopLockTask", Null)
    WriteLockState(False) ' This line is not necessary
End Sub
My mistake then. Thank you for the response. I have an other question. As I said I have already run the kiosk example. I have written also the command in cmd and I have been owner. I do not understand if I have to do that again for my app.
I have attached the kiosk method to my program but when I try to run, it does not do anything. Do I have to be again owner of the device/app for my app?
Note that the example has name b4a.example but my app another name and I have update manifest to what is needed.
 
Upvote 0

Nikan99

Member
Erel's example is complete, you need to follow the steps carefully.

Did you follow this step?
Yes! I did remove the existing accounts. When I did that, I became owner of the device and run the erel's kiosk example. But when I run my own app, kiosk function did not work.
Actually I ask if I have to become again owner of the device but this time with my app's name (package name). If yes how can I do that? When I try to re-run the command it does not work.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I became owner of the device and run the erel's kiosk example
you should have used your app. remove everything and do it again i guess. Can´t really give a congrete advice as i did not used kiosk-apps in the past.

You need to go back the steps and deactivate erels kioskapp. And instead set yours. There can be only one Kioskapp on the device at any time as far as i know.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
usage: dpm [subcommand] [options]
usage: dpm set-active-admin [ --user <USER_ID> | current ] <COMPONENT>
usage: dpm set-device-owner [ --user <USER_ID> | current *EXPERIMENTAL* ] [ --name <NAME> ] <COMPONENT>
usage: dpm set-profile-owner [ --user <USER_ID> | current ] [ --name <NAME> ] <COMPONENT>
usage: dpm remove-active-admin [ --user <USER_ID> | current ] [ --name <NAME> ] <COMPONENT>

dpm set-active-admin: Sets the given component as active admin for an existing user.

dpm set-device-owner: Sets the given component as active admin, and its package as device owner.

dpm set-profile-owner: Sets the given component as active admin and profile owner for an existing user.

dpm remove-active-admin: Disables an active admin, the admin must have declared android:testOnly in the application in its manifest. This will also remove device and profile owners.

dpm clear-freeze-period-record: clears framework-maintained record of past freeze periods that the device went through. For use during feature development to prevent triggering restriction on setting freeze periods.

dpm force-network-logs: makes all network logs available to the DPC and triggers DeviceAdminReceiver.onNetworkLogsAvailable() if needed.

dpm force-security-logs: makes all security logs available to the DPC and triggers DeviceAdminReceiver.onSecurityLogsAvailable() if needed.
usage: dpm mark-profile-owner-on-organization-owned-device: [ --user <USER_ID> | current ] <COMPONENT>
 
Upvote 0

Nikan99

Member
Upvote 0

Nikan99

Member
I also have another question. I have find to settings that I can make my app with admin user. If I do that will kiosk work? Or I need to remove the previous active admin privileges of the example?
 
Upvote 0
Top