android - 当我使用 'poweroff' 重新启动时,如何在 HTC 中获取 Boot_Complete Intent ?

标签 android android-intent

我想在获得 BOOT_COMPLETE Intent 后启动服务。在 HTC Explorer 中,有 2 个重启选项:“关机”和“重启”。当我使用“重新启动”时,我正确地获得了 BOOT_COMPLETE Intent 。但是当我使用“poweroff”时没有获得 BOOT_COMPLETE Intent ,因此我无法启动服务。只有在 HTC 重新启动后我才能得到他们的 Intent 吗?

我一直在谷歌浏览,找不到任何提示。我被困住了,请帮助我

我使用了这个代码<action android:name="android.intent.action.BOOT_COMPLETED"/>在 list 中但没有用

提前致谢

最佳答案

某些 HTC 设备可以启用“快速启动”功能,该功能更像是深度休眠而不是真正的重新启动,因此不应给出 BOOT_COMPLETE Intent 。另请确保该应用程序未安装在 SD 卡上,因为它可能因此无法收到 BOOT_COMPLETED。

这可能也很有趣:

http://commonsware.com/blog/2011/07/13/boot-completed-regression-confirmed.html

http://arthurfmay.blogspot.jp/2011/06/broadcastreceiver-bootcompleted-and.html

尤其是在提到“快速启动”选项的地方:

http://groups.google.com/group/android-developers/browse_thread/thread/56562e4de4919dc6

编辑:

简单地使用怎么样:

Intent.ACTION_SCREEN_ON

然后您可以检查服务是否正在运行:

public static boolean ServiceRunning(Context cx) 
{   ActivityManager manager = (ActivityManager) cx.getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
    {   if ("<<<service name goes here>>>".equals(service.service.getClassName()))
        {   return true;
        }
    }
    return false;
}

如果不只是启动它:

public static void ServiceCheck(Context cx)
{   if(ServiceRunning(cx) == false)
    {   Intent svc = new Intent(".<<<Servicename>>>");
        cx.startService(svc);
        Log.i("Service-Check","Service Starting");
    }
    else
    {   Log.i("Service-Check","Service Existing");
    }
}   

关于android - 当我使用 'poweroff' 重新启动时,如何在 HTC 中获取 Boot_Complete Intent ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10411731/

相关文章:

android - ContentProvider 何时真正创建?

android - 当我设置 Custom buildTypes 时,我遇到了一些错误。谁能帮助我?

android - 无法通过 Android 设备中的 Worklight http 适配器连接到后端

Android:创建代理服务器

android - 如何在代码中设置 child 体重?

Android - 打开电子邮件应用程序?

android - 如何从我的应用程序将电子书上传到 google play book?

java - Android 类型 new View.OnClickListener(){} 未定义方法 startActivity(Intent)

android - 如何正确使用Intent

android - 如何从 sony smartwatch 2 更改主机应用程序中的文本?