Android的Kiosk模式

时间:2014-07-08 08:59:08

标签: android cordova kiosk-mode

我在android平板电脑的phonegap上写了一个混合应用程序。现在我希望平板电脑只显示我的应用程序。基本上我希望平板电脑始终处于仅运行我的应用程序的信息亭模式。这样所有按钮都被禁用。我在网上寻找解决方案,其中一个是使用" surelock",但它没有做到以上所有。另一个选择是编写我自己的ROM,但是我找不到任何好的教程。任何人都可以帮助我PLZ?

6 个答案:

答案 0 :(得分:7)

我做了很多研究,现在终于对我得到的东西感到满意。

您基本上有两个选择:

  1. 创建自己的自定义ROM,这对我来说不是最好的解决方案。

  2. 使用各种黑客自定义平板电脑。

  3. 所以我将解释第二个选项。

    首先,您需要根设备。有各种方法,但我更喜欢通过oneclick软件生根。对于中国平板电脑,您可以使用VROOT,而对于更受欢迎的平板电脑则使用Kingo root。

    现在,您已将设备设置为root,我们可以摆脱顶部和底部栏。

    private void hideBar(){
        try
        {
            Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 42 s16 com.android.systemui"}); 
            proc.waitFor();
        }
        catch(Exception ex)
        {
            Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
            Log.e("ROOT ERROR", ex.getMessage());
        }
    }
    

    这将使顶部和底部栏消失。但是,您可能需要一种方法再次显示条形图。为此你可以使用:

    public void showBars(){
        try 
        {
            String command;
            command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";
            String[] envp = null;
            Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command }, envp);
            proc.waitFor();
        } 
        catch(Exception ex)
        {
            Toast.makeText(context.getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
        }
    }
    

    好的,所以我们还有,剩下的就是让你的应用程序在启动时启动。 为此,您可以找到许多教程,只需谷歌。

答案 1 :(得分:2)

使用Android L-release(Lollipop),有一项称为固定的功能,几乎相当于Kiosk模式。这是一个解释如何设置的链接。

我相信Apple首先在iOS中推出了这款产品。尽管OP没有问过,我也提供iOS的详细信息:

Android:http://www.cnet.com/how-to/ho-to-pin-apps-in-android-5-lollipop/

iOS:http://www.webascender.com/Blog/ID/447/How-to-Setup-Kiosk-Mode-Lock-Your-iPad-to-Just-One-App#.VzrO2ZN95E5

答案 2 :(得分:1)

我认为有一种替代解决方案,而无需根植设备。我的老板让我避免生根,所以经过一些研究后我才开始解决这个问题。 结果,没有完成任何黑客攻击,系统密钥仍然存在,但用户无法离开应用程序并启动另一个应用程序。所以,我做了以下步骤。

1。 通过编辑清单,可以为TitleBar设置不使用ActionBarActivity的全屏主题,如下所示:

<application
    ...
    android:theme="android:Theme.Holo.NoActionBar.Fullscreen" >

2。 通过覆盖Activity class:

的方法禁用后退按钮
@Override
public void onBackPressed() {
    return;
}

3。 将以下字符串添加到清单(相应的Activity的意图过滤器):

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.HOME" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

现在您可以使用您的应用程序替换默认主屏幕。但是,通过点击&#34;最近的应用程序&#34;退出应用程序的能力仍然存在。按钮并选择另一个。

4。 为了避免所有其他离开应用程序的方法,我添加了一项服务,每次暂停活动时都会启动该服务。此服务重新启动应用程序并发送有关它的通知。 服务代码:

public class RelaunchService extends Service {
    private Notification mNotification;
    private Timer mTimer;

    public RelaunchService() {
    }

    @Override
    public void onCreate(){
        super.onCreate();
        if (mNotification == null) {
            Context context = getApplicationContext();
            Intent notificationIntent = new Intent(this, FullscreenActivity.class);
            PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                    notificationIntent, 0);
            Notification.Builder mBuilder = new Notification.Builder(context)
                    .setSmallIcon(android.R.drawable.ic_dialog_info)
                    .setWhen(System.currentTimeMillis())
                    .setContentIntent(contentIntent)
                    .setContentTitle("Your app title")
                    .setContentText("App is being relaunched");
            mNotification = mBuilder.getNotification();

            mTimer = new Timer("LaunchTimer");
        }
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        super.onStartCommand(intent, flags, startId);
        startForeground(1, mNotification);
        mTimer.schedule(new TimerTask() {
            @Override
            public void run() {
                Intent intent = new Intent(RelaunchService.this, YourActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }
        }, 300);
        return START_STICKY;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        stopForeground(true);
        mTimer.cancel();
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }
}

添加到Activity类的代码:

@Override
protected void onResume() {
    super.onResume();
    exitAllowed = false;
    Intent servIntent = new Intent(this, RelaunchService.class);
    stopService(servIntent);
}

@Override
protected void onPause() {
    super.onPause();
    savePersistentData();
    if (!exitAllowed) {
        Intent servIntent = new Intent(this, RelaunchService.class);
        startService(servIntent);
    }
}

当您要关闭应用程序时,exitAllowed布尔变量应该被绑定到true。你可以考虑采用某种方式来做到这一点,例如点击&#34;退出&#34;按钮。在我的情况下,需要输入密码。

答案 3 :(得分:0)

三星手机中可以使用非root解决方案,查看免费的Superlock应用程序

https://play.google.com/store/apps/details?id=com.superkiosk.ospolice.superlocklite&hl=en_GB

答案 4 :(得分:0)

您不需要创建自定义ROM甚至根设备来获取信息亭模式。通常强烈建议根设备将在现场外,特别是如果您的应用将具有敏感数据。

12oz鼠标的答案(https://stackoverflow.com/a/29560438/2888763)在大多数情况下都可以使用,但它并不完全安全。您的应用或服务可能始终被系统或崩溃所杀死,从而为用户提供对设备的完全访问权限。

实现自助终端模式的一种方法是使用Google的锁定任务模式 -  这与屏幕钉扎不同  (https://developer.android.com/work/cosu.html)。其中的链接列出了一些锁定任务模式功能,例如:将一个应用程序固定到主屏幕并禁用/隐藏Home和Recents按钮。该链接还说明了为什么Google解决方案的最大问题是设置它的复杂性。您要么必须使用第三方企业移动管理(EMM)解决方案&#34;或者&#34;创建自己的DPC应用程序&#34;。如果您无法访问Google Play服务,Google的COSU解决方案也可能无效。

另一种选择是使用像Mason(https://bymason.com/)这样的移动部署平台,您可以在几分钟内使用自助服务终端模式等功能构建自定义Android操作系统。然后,您可以远程将操作系统或应用程序更新部署到所有设备。

随意直接ping我:trevor @ bymason.com

免责声明:我为Mason工作

答案 5 :(得分:0)

我最终确定了这个解决方案,不需要root,外部应用程序,可以在浏览器,webapps和本机应用程序上使用:

沉浸式全屏模式

  1. 使用adb,检查您的设备是否显示为adb devices(必须启用开发选项)
  2. 找到您要全屏显示的应用的ID(如果它是一个网络应用,它是使用的浏览器,如org.mozilla.firefoxcom.android.chrome),它位于Play商店网址中:https://play.google.com/store/apps/details?id=org.mozilla.firefox
  3. 使用您的ID
  4. 取代adb shell settings put global policy_control immersive.full=org.mozilla.firefox替换org.mozilla.firefox的命令

    此处有更多信息:https://www.howtogeek.com/302194/how-to-force-any-android-app-into-fullscreen-immersive-mode-without-rooting/

    与屏幕固定相结合:

    1. 在Android设备上启动“设置”应用。
    2. 向下滚动,直至找到“安全”选项。点击它。
    3. 在“安全性”页面的底部,点击屏幕固定。
    4. 将开关滑动到“开”位置。
    5. 打开您的应用,使用最近的应用进入视图,然后点按当前应用预览中的图钉图标(右下角)