Giter Club home page Giter Club logo

cordova-plugin-android-kiosk's Introduction

cordova-plugin-android-kiosk

Cordova single purpose applicaion plugin for Android. The plugin make user can't excapt from you app because your app is device owner it cann't unpin. your app will start when boot complete or upgrade complete, It is available after Android 5.0 bacause it using the LockTask mode feature .

install

cordova plugin add cordova-plugin-android-kiosk

usage

Kiosk is a cordova.plugin.kiosk.Kiosk to lock or unlock you app to the Only one app.

lock or unlock the app to Single Pourse device

function success(message){
    console.log("success");
}

function error(message){
    console.log("error: reason is " + message);
}

Kiosk.lock(success, error, boolean enable); // the boolean parameter is enable or disable this mode.

check the current lock state.

function success(message){
    console.log("locked = " + message); //true or false.
}
Kiosk.isLocked(success)

you could switch the launcher using switchLauncher, it will unlock and show launcher chooser.

Kiosk.switchLauncher();

you have to set you app to the device owner forllow google AOSP design.

adb shell dpm set-device-owner com.example.template/.kiosk.plugin.MyAdmin

the setting will sotren at /data/system/device_policy.xml(before android 6.0) /data/system/device_policy_2.xml(> android 6.0)

First, create a file device_owner.xml with following content:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<root>
    <device-owner package="com.myDomain.myPackage" name="" component="com.example.template/com.example.template.kiosk.plugin.MyAdmin" userRestrictionsMigrated="true" />
</root>

on android 8.0

/data/system # cat device_owner_2.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<root>
<device-owner package="com.example.template" name="" component="com.example.template/com.example.template.kiosk.plugin.MyAdmin" userRestrictionsMigrated="true" />
<device-owner-context userId="0" />
</root>

chown system:system device_owner.xml

the cordova plugin source and target tag in plugin.xml is sutable for my project, the package name is com.example.template, if your project name is different, please using your pakcage name instand of it.

cordova-plugin-android-kiosk's People

Contributors

forestgun avatar shougao avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.