我在Android开发方面是个新手,我正在为孩子们开发一个应用程序。我希望应用程序在设备启动时自动启动。当应用程序运行时,我希望它阻止访问任何其他屏幕。禁用主页按钮,禁止访问浏览器、设置等。
这有可能做到吗?我偶然发现了这个链接http://www.androidsnippets.com/autostart-an-application-at-bootup,但一些人认为这不是允许活动自动启动的好方法。
谢谢:-)
发布于 2013-05-09 20:07:24
听起来你需要你自己的启动器,因为只有启动器才能阻止访问不必要的屏幕,而Home按钮将被你的启动器“阻止”。
它还将解决“启动”问题。
您所需要做的就是在您的AndroidManifest中声明Activity,如下所示:
<activity
android:name="your.package.ActivityName
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>激发你的创造力,根据你的需要构建启动器。
祝好运!
发布于 2013-05-09 20:01:01
这将在您的设备中将应用程序设置为启动应用程序创建类扩展BroadCast接收器
public class BootUpReciever extends BroadcastReceiver
{
@Override
public void onReceive(final Context context, Intent intent) {
Intent i = new Intent(context, ServerPreferenceActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}将清单文件的权限添加到额外的启动接收器
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />在manifest.xml中注册扩展广播接收器的接收器
<receiver android:enabled="true" android:name="com.app.reciever.BootUpReciever">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>注意:在src文件夹中的单独包中创建receiver类,以获得工作实现。
发布于 2013-05-09 20:09:32
关于你的问题:
您可以实现用于捕获RECEIVE_BOOT_COMPLETED事件的BroadcastReceiver。参见this post。
您可以在活动被销毁或暂停时重新启动活动。您可以在后台Service中进行检查。有关更多信息,请查看this post。
根本不可能。你必须依赖于2的结果。这里。
类似于3。-你真的无法避免这个。但是,您可以检查您的应用程序是否在顶部,如果不是,则重新启动它。
希望这能帮到你。干杯!
https://stackoverflow.com/questions/16461196
复制相似问题