问题 Android的Kiosk模式


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


3184
2017-07-08 08:59


起源



答案:


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

你基本上有两个选择:

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

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

所以我将解释第二种选择。

首先,您需要根设备。有各种方法,但我更喜欢通过oneclick软件生根。对于中国平板电脑,您可以使用VROOT,对于更受欢迎的平板电脑,请使用Kingo 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();
    }
}

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


6
2017-08-21 07:47



怎么样的主页按钮 - user1532587
你的意思是你有一个实体主页按钮? - Mikhail Kim
我做。这是三星的趋势。顶级菜单栏? - user1532587


答案:


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

你基本上有两个选择:

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

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

所以我将解释第二种选择。

首先,您需要根设备。有各种方法,但我更喜欢通过oneclick软件生根。对于中国平板电脑,您可以使用VROOT,对于更受欢迎的平板电脑,请使用Kingo 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();
    }
}

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


6
2017-08-21 07:47



怎么样的主页按钮 - user1532587
你的意思是你有一个实体主页按钮? - Mikhail Kim
我做。这是三星的趋势。顶级菜单栏? - user1532587


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

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

安卓: 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
2018-05-17 09:34





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

1。 通过编辑清单设置全屏主题没有 TitleBar 和 ActionBar 适当的 Activity, 喜欢这个:

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

2。 通过覆盖方法禁用后退按钮 Activity 类:

@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>

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

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 应该将boolean变量赋值给 true当你想关闭应用程序时。您可以考虑某种方法,例如单击“退出”按钮。在我的情况下,需要密码才能退出。


1
2018-04-10 11:35





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

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


0
2018-03-30 18:13



我需要中国平板电脑的解决方案 - Mikhail Kim


您无需创建自定义ROM甚至根设备来获取信息亭模式。通常强烈建议  将在该字段中出现的根设备,尤其是当您的应用程序具有敏感数据时。

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

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

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

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

免责声明:我为梅森工作


0
2018-04-26 21:56





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

沉浸式全屏模式

  1. 使用adb,检查您的设备是否可见 adb devices (必须启用开发选项)
  2. 找到你想要全屏的应用程序的ID(如果它是一个webapp,它就像它使用的浏览器一样 org.mozilla.firefox 要么 com.android.chrome)它在Play商店网址中: https://play.google.com/store/apps/details?id=org.mozilla.firefox
  3. 超出命令 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. 打开您的应用,使用最近的应用进入视图,然后点按当前应用预览中的图钉图标(右下角)

0
2018-03-21 17:45