如何获得在HTC Boot_Complete意图当我使用'关机'的重新启动? [英] How to get Boot_Complete intent in HTC when i use 'poweroff' for reboot?

查看:185
本文介绍了如何获得在HTC Boot_Complete意图当我使用'关机'的重新启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要开始的服务,一旦我得到BOOT_COMPLETE意图。在HTC Explorer中有2个选项,重新启动这些都是关机和重新启动。当我用'重启'我得到BOOT_COMPLETE意图正常。但是当我使用'关机'没有得到BOOT_COMPLETE意图,所以我不能够启动服务。是他们的任何意图,我可以得到的只是在重启后的HTC?

I want to start service once i get BOOT_COMPLETE intent. In HTC explorer there are 2 options for reboot those are 'poweroff' and 'restart'. When i use 'restart' i am getting BOOT_COMPLETE intent properly. But when i use 'poweroff' not getting BOOT_COMPLETE intent so i am not able to start service. Is their any intent i can get only after reboot in HTC?

我一直在冲浪谷歌,找不到任何线索。我坚持请帮我

I have been surfing Google, could not find any hint. I am stuck please help me out

我用这个code <作用机器人:名称=android.intent.action.BOOT_COMPLETED/> 的清单,但没有用。

I used this code <action android:name="android.intent.action.BOOT_COMPLETED"/> in manifest but no use

在此先感谢

推荐答案

部分HTC设备可以启用快速启动功能,它更像是一个深深的冬眠,而不是一个真正的重新启动,因此不应该给BOOT_COMPLETE意图。另外,还要确保该应用程序不是在SD卡,否则可能无法收到,因为该BOOT_COMPLETED上安装。

Some HTC devices can enable a "fast boot" feature that is more like a deep hibernation and not a real reboot and therefore should not give the BOOT_COMPLETE intent. Also make sure that the app is not installed on the SD card as it might not receive the BOOT_COMPLETED because of that.

这也可能是有趣的:

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

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

和尤其是这其中,被提及的快速启动选项:

And especially this where the "fast boot" option is being mentioned:

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

编辑:

如何简单地使用:

Intent.ACTION_SCREEN_ON

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

And you can then check if the service is running:

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;
}

如果它不只是启动:

And if it isn't just start it:

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");
    }
}   

这篇关于如何获得在HTC Boot_Complete意图当我使用'关机'的重新启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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