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?
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
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.
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.
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.
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>
Unfortunately I can not operate command "adb shell dpm remove-active-admin b4a.example/MyDeviceAdminReceiver" as I had not write to manifest "android:testonly = "true"".
Update that to https://www.b4x.com/android/forum/threads/device-owner-tasklock-kiosk-apps-2017.81765/#post-518018 so the new users know about it.
Do you know a way that I can uninstall or remove the example? Note that I can not do a factory reset to my device.
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?