如何在电话开启时自动运行应用程序
答
你需要声明一个广播监听器监听项值
<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);
使用上述思路的另一个例子:auto start app
我在夫妻俩尝试过,但我的应用程序没有启动编辑在启动.. – 2016-02-04 14:53:17
如果你正在开始一项活动,上述将工作。对于服务,您将不得不调用startService()。如果您发现无法正常工作,则应将设备连接到计算机并观看系统日志。如果有权限问题或其他问题阻止它,它会显示在那里。 – ekawas 2016-02-04 15:17:25