在Android上孩子的安全应用程序 [英] toddler safe app on android

查看:135
本文介绍了在Android上孩子的安全应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,这应该是孩子安全。 意思就是说,它会阻止任何单一的按键触感,又处理长pressing用于退出应用程序。 这是为了让中,孩子会从做(太)讨厌的事情,而稳打稳扎。 截至2.3.4版本,我成功地实现了这一点。 不过,现在我有2个问题:

I have an app, that should be toddler safe. Meaning that, it blocks any single key touch, yet handles long pressing for exiting the app. This is so that, the toddler will be safe from doing (too) nasty things while playing. Up to version 2.3.4, I succeeded in achieving this. However, now I have 2 problems:

  1. 在蜂窝,我的状态栏通知可以是pssed在$ P $。另外,我有切换窗口键可以是pressed。我会成功,但它的唯一的事情就是朦胧状态栏。
  2. 在冰淇淋三明治(使用模拟器,我还没有使用这个版本的真实设备),调用next code的时候,我得到它甚至不能被捕获的异常。 异常:

  1. On honeycomb, I have the status bar notifications which can be pressed on. Also , I have the switch-windows key which can be pressed. The only thing I succeeded with it is to dim the status bar.
  2. On ice cream sandwich (using emulator, I still don't have a real device with this version), when calling the next code, I get an exception which cannot even be caught. the exception:

java.lang.IllegalArgumentException:如果窗口被加入后窗口类型不能改变

java.lang.IllegalArgumentException: Window type can not be changed after the window is added.

在code:

@Override
public void onAttachedToWindow()
  {
  this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
  super.onAttachedToWindow();
  }

我该怎么办?

What can I do?

推荐答案

对于Android版本4(API 14及以上),有可能使用:         getWindow()的setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

for android version 4 (API 14 and up) , it might be possible to use : getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

然而,在模拟器上,它不会阻止home键,所以它有点没用。 我仍然不知道它是否工作正常,在真实设备上。

however,on the emulator , it doesn't block the home button , so it's kinda useless . i still don't know if it works fine on real devices.

也许是可以使用下一个解决方法: 设置应用程序为默认主屏幕应用程序。 如果home键是pressed而应用程序是活跃的,捕获它,什么也不做。 如果home键是pressed,而应用程序是在后台(或关闭),打开previously选择默认主页的应用程序。

maybe it's possible to use the next workaround: set the app as the default home screen app . if the home button was pressed while the application was active, capture it and do nothing. if the home button was pressed while the application was on the background (or closed) , open the previously selected default home app .

另外,我可以要求用户设置默认首页启动的应用程序为我的每次启动时间,并重新复位(无论对previous之一或全部复位)关闭后。

alternatively , i could ask the user to set the default home launcher app as mine for each time it is started , and reset it again (either to the previous one , or total reset) after it is closed.

这可能吗? 如果是的话,怎么办?

is it possible? if so, how?

由于机器人棒棒糖(版本5.0是API 21),有一个屏幕,钉扎的一种方式,这可以由用户或应用程序(联系的 此处 ):

Since Android Lollipop (version 5.0 which is API 21), there is a way of screen-pinning, and this can be turned on by the user or the app (link here) :

有两种方法可以激活屏幕钉扎:

There are two ways to activate screen pinning:

手动:用户可以启用屏幕寄托在设置>安全>   屏幕钢钉,并通过触摸选择他们想要销的任务   在最近通话屏幕上绿色的图钉图标。编程:要激活   屏幕穿针编程,从您的应用程序调用startLockTask()。   如果请求的应用程序是不是器件拥有者,将提示用户   确认。设备所有者的应用程序可以调用setLockTaskPackages()   方法,使应用程序成为pinnable未经用户确认   一步。

Manually: Users can enable screen pinning in Settings > Security > Screen Pinning, and select the tasks they want to pin by touching the green pin icon in the recents screen. Programmatically: To activate screen pinning programmatically, call startLockTask() from your app. If the requesting app is not a device owner, the user is prompted for confirmation. A device owner app can call the setLockTaskPackages() method to enable apps to be pinnable without the user confirmation step.

它有什么作用?继续读下去,看看:

What does it do? read further and see:

当任务锁定处于活动状态,以下行为发生:

When task locking is active, the following behavior happens:

状态栏是空白的,和用户通知和状态信息   被隐藏。 Home和最近的应用程序按钮是隐藏的。其他应用程序   无法启动新的活动。当前的应用程序可以开始新   活动,只要这样做不会产生新的任务。当屏幕   钉扎由器件拥有者调用时,用户仍然锁定到您的   应用程序直到应用程序调用stopLockTask()。如果屏幕钉扎的活动   由另一个应用程序,不是器件拥有者或由用户直接的   用户可以通过按住后端及近期按钮退出。

The status bar is blank, and user notifications and status information are hidden. The Home and Recent Apps buttons are hidden. Other apps cannot launch new activities. The current app can start new activities, as long as doing so does not create new tasks. When screen pinning is invoked by a device owner, the user remains locked to your app until the app calls stopLockTask(). If screen pinning is activity by another app that is not a device owner or by the user directly, the user can exit by holding both the Back and Recent buttons.

不仅如此,但据 这个帖子 ,你也可以切换此不用户确认,退出这个特殊的状态将是你的应用程序的逻辑下。

Not only that, but according to this post, you can also toggle this without user-confirmation, and exiting this special state would be under your app's logic.

看起来像是一个完美的事情,孩子的安全应用程序。

Seems like the perfect thing for toddler safe app.

这篇关于在Android上孩子的安全应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆