Android的 - 如何获得与安装在SD卡的应用程序的BOOT信号?如何获得、应用程序、信号、安装在

由网友(心已打烊)分享简介:我需要为一个应用程序时,设备启动开始通知服务。我实现了一个广播接收器侦听到启动信号,以启动该服务。I need to start a notification service for an application when the device boots. I have implemented a Broadcas...

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

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?

任何破解这个?

让我知道!

谢谢!

推荐答案

您既可以:

注册在的AccountManager 帐户,并成立了一个同步服务(的教程1 ,的 tutorial2 ) - Android将自动启动为您服务;或收听一些其他节目,以及(如屏幕关闭/屏幕上),并测试您是否需要启动通知服务或没有。 Register an account in the AccountManager and set up a sync service (tutorial1, tutorial2) -- Android will start your service automatically; or 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).

阅读全文

相关推荐

最新文章