Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to force app in kiosk mode #519

Open
magic3584 opened this issue Jan 22, 2024 · 4 comments
Open

How to force app in kiosk mode #519

magic3584 opened this issue Jan 22, 2024 · 4 comments

Comments

@magic3584
Copy link

magic3584 commented Jan 22, 2024

I have an app written with flutter and using the kiosk package. Then I called startKioskMode() when app first launch. But it shows with a selection: No, thanks and Got it.
If I choose No thanks then the koisk mode is exit.

Below shows in https://pub.dev/packages/kiosk_mode

If DevicePolicyManager#isLockTaskPermitted(String) returns true for this component, the current task will be launched directly into LockTask mode.

But I'm not familiar with android so I don't know how to add this in flutter.

How can I force the app in koisk mode until I call stopKoiskMode

@ookami-kb
Copy link
Contributor

Android doesn't provide the full kiosk experience to all apps, you need special permissions and/or a companion app for that. You can find more info here: https://ookamikb.dev/blog/2018/07/19/developing-kiosk/

@magic3584
Copy link
Author

Thanks for reply!
I have followed the link and works fine by adb test. I am truely new to android and don't know how to distribute it with qrcode? Do I have to write another DPC app?

And another problem is that it didn't work if I run directly other than using adb.

And when I using the file generated by gpt (https://github.com/magic3584/API/blob/master/DeviceOwnerUtil.kt), and called like

class MainActivity: FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
        super.onCreate(savedInstanceState, persistentState)
//    DeviceOwnerUtil.setDeviceOwner(this);
    }
}

then the app can not be uninstalled. I have to factory the device.

Could u plz add some details about android in readme?

@fabioselau077
Copy link

Thanks for reply! I have followed the link and works fine by adb test. I am truely new to android and don't know how to distribute it with qrcode? Do I have to write another DPC app?

And another problem is that it didn't work if I run directly other than using adb.

And when I using the file generated by gpt (https://github.com/magic3584/API/blob/master/DeviceOwnerUtil.kt), and called like

class MainActivity: FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
        super.onCreate(savedInstanceState, persistentState)
//    DeviceOwnerUtil.setDeviceOwner(this);
    }
}

then the app can not be uninstalled. I have to factory the device.

Could u plz add some details about android in readme?

Hello, I need my app to always stay open, when I restart the device it starts with it... any ideas?

@Deepak-GP
Copy link

@fabioselau077 If you want to start your app in Kiosk mode as soon as the device restarts, you need to implement the the RECEIVE_BOOT_COMPLETED receiver in the native android. (Not sure any package exists to implement this directly in flutter).

And in this receiver, call the startActivity for your app package.

This way, when the when the device restarts, the boot complete receiver gets kicked in. And the app will be loaded.
And the logic for enabling the kiosk mode can be handled in your flutter layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants