Android的 - 如何获得与安装在SD卡的应用程序的BOOT信号? [英] Android - How to receive the BOOT signal with an application installed on sdcard?

查看:161
本文介绍了Android的 - 如何获得与安装在SD卡的应用程序的BOOT信号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为一个应用程序时,设备启动开始通知服务。我实现了一个广播接收器侦听到启动信号,以启动该服务。

I need to start a notification service for an application when the device boots. I have implemented a BroadcastReceiver that listens to the boot signal in order to start the service.

然而,这只有当该应用程序上没有安装SD卡(因为之前被安装在SD卡上接收到信号)。是否有任何解决方案,以保持安装在SD卡应用,但仍然收到信号?

However, this works only if the application is not installed on sdcard (because the signal is received before the sdcard is mounted). Is there any solution to keep installing the application on sdcard and yet still receive that signal?

任何破解这个?

让我知道!

谢谢!

推荐答案

您既可以:


  1. 注册在的AccountManager 帐户,并成立了一个同步服务(的教程1 ,的 tutorial2 ) - Android将自动启动为您服务;或

  2. 收听一些其他节目,以及(如屏幕关闭/屏幕上),并测试您是否需要启动通知服务或没有。

  1. Register an account in the AccountManager and set up a sync service (tutorial1, tutorial2) -- Android will start your service automatically; or
  2. Listen for some other broadcasts as well (such as screen off / screen on) and test whether you need to start your notification service or not.

我知道这些是不容易/方便的解决方案,但他们唯一的我能想到的。如果有人知道一个更好的解决方案,我会很乐意给予好评。)

I realize these are not easy / convenient solutions, but they're the only ones I can think of. If anyone knows a better solution, I'll be happy to upvote :).

另一种解决方案(这可能最终会连同上述之一使用)是启动服务(或检查它是否需要启动)时,您的应用程序从应用程序启动器启动时(即主活动启动)。

Another solution (which could eventually be used in conjunction with one of the above) is to start your service (or check if it needs to be started) when your application is launched from the application launcher (i.e. when the "main" activity is started).

这篇关于Android的 - 如何获得与安装在SD卡的应用程序的BOOT信号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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