始终保持相同的应用程序 [英] Keep the same application always
问题描述
我不确定这是否可以完成.我想开发一个网站并将其始终保存在设备中,而不能退出.我的意思是禁用硬件/软件按钮并且只能关闭/打开电源.当您自动重新启动时,将启动该应用程序.我认为这可以通过手机或类似的东西来完成,但我不知道我该如何开始.有什么想法吗?
I not sure if this can be done. I want to develop a website and keep it in the device always, without the possibility of exit. I mean disabling the hardware/software buttons and only being able to power off/on. When you reboot automatically will be launch the app. I think this can be done rooting the phone or something similar, but I don't know how can I start. Any idea?
也许这无法通过 HTML 页面完成,而是将该网站嵌入到应用程序中并保持该应用程序始终处于活动状态...
Maybe this cannot be done with a HTML page, but embedding that website inside an application and keeping that application always active...
我可以从哪里开始?
推荐答案
听起来您想要实现类似 Kioskmode 的东西.Kioskmode 仅适用于三星设备.在其他设备上,您必须自己实现 Kiosk.但这是可能的!网上有一些不错的教程.但是,您需要实现一个应用程序来获取用户交互.
Sounds like you want to implement something like a Kioskmode. The Kioskmode is only available on Samsung devices. On other devices you have to implement a Kiosk by yourself. But it is possible! There are some nice tutorials in the web. However you need to implement an application to get the user interactions.
首先,您需要在启动设备后激活 Kiosk.您可以使用广播接收器来获取启动事件:
First of all you need to activate the Kiosk after booting the device. You can use a Broadcast Reciever to get the Boot Event:
<receiver android:name=".BootReceiver">
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
您必须在清单文件中声明权限:
You have to declare the permission in your manifest file:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
您可以在扩展 BroadcastReciever 的类中开始您的实现.从实际的 android 上下文启动 Activity.
You can start your implementation in a class witch extends the BroadcastReciever. Start the activity from the actual android context.
public class BootReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Intent kioskIntent = new Intent(context, KioskMode.class);
kioskIntent .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(kioskIntent);
}
}
在活动中,您可以禁用设备的每个按钮,例如后退按钮等.您可以在以下链接中找到有关开发自助服务终端的好教程,它展示了如何禁用电源按钮、主页按钮、后退按钮等:
In the activity you can disable every button of the device, like back pressed, etc. You can find a good tutorial for developing a kiosk under the following link, it shows how to disable power button, home button, back pressed,etc.:
http://www.andreas-schrade.de/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/
要禁用状态栏,您只需使用主题将其隐藏:
To disable the statusbar you just need to hide it with a theme:
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
要显示 HTML 页面,您可以使用 WebView.但是在 webview 中是 javascript 并且所有错误都被禁用.因此,如果您只想在页面上显示一些信息,那么您可以使用 WebView.
To display a HTML Page you can use a WebView. However in a webview is javascript and all errors disabled. So if you just want to show some information on the page your good with a WebView.
http://developer.android.com/reference/android/webkit/WebView.html
这篇关于始终保持相同的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!