如何自动运行一个应用程序时,手机处于开机状态 [英] How to autorun an application when the Phone is switched ON

查看:157
本文介绍了如何自动运行一个应用程序时,手机处于开机状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以请您给我code或链接或概念的自动运行在Android设备中的android应用..只要设备处于开机状态,应用程序应该自行启动,与出用户的干扰。

Can anyone please give me code or links or concept for running an android application on android device automatically.. whenever the device is switched on, application should start on its own, with out the interference of the user.

感谢你..

推荐答案

您需要声明一个广播监听器监听RECEIVE_BOOT_COMPLETED

You need to declare a broadcast listener that listens for RECEIVE_BOOT_COMPLETED

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

在你的监听器:

Intent myStarterIntent = new Intent(context, YOUR_CLASS_TO_START.class);
/* Set the Launch-Flag to the Intent. */
myStarterIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myStarterIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
/* Send the Intent to the OS. */
context.startActivity(myStarterIntent);

另一个例子使用了上述观点:自动启动应用

这篇关于如何自动运行一个应用程序时,手机处于开机状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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