哪个事件告诉您该装置已成功启动 [英] Which event tells you that the device is successfully started

查看:216
本文介绍了哪个事件告诉您该装置已成功启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个应用程序,自动启动手机重新启动时。我想运行某些事件的时候,手机及其完整地重新启动。该了UiApp运行设备完成他复位之前也因为我配置的应用为自动启动应用程序。

I am making an application that auto starts when the phone restarts. I want to run some events when the phone complets its restart. The UiApp is running even before the device finishes his reset cause I configured the app as an auto start app.

我应该听什么事件也是一样,当手机完成了重新引导,而不是在之间开始?

What event should I listen too and that starts when the phone completes the reboot, not in between?

感谢

推荐答案

有可能知道,如果系统在启动时使用:

It is possible to know if the system is in startup by using :

ApplicationManager.isStartup()

您需要查询该使用计时器,直到它返回false。然而,它必须牢记的是,这意味着操作系统已经启动,并且系统能够运行应用程序。这并不意味着您的应用程序来运行整个环境设置完全。例如(由迈克尔说明)microSD卡可能没有被安装,网络连接可能不成立,或者您的应用程序可能会依赖一些其他的服务尚未公布。这是由你来验证你开始你的应用程序的工作之前,他们都可用。

You will need to poll this using a timer till it returns false. However it must be borne in mind that this means that the OS has booted and the system is able to run the application. It does not mean that the entire environment for your application to run is set up completely. For example (as noted by Michael) microSD card might not have been mounted, network connectivity might not been established, or some other service on which your application might depend is not yet available. It's up to you to verify they are available before you begin working of your application.

您需要采取的方法是:


  1. 如果投票返回isStartup假(系统是不是在启动阶段)

  2. 实施FileSystemListener检查microSD卡安装。

请注意,对于一个microSD卡装入名称为SD卡。

Note that mount name for a microSD card is "SDCard".

class FileSystemListenerImpl implements FileSystemListener
 {
      final static String SDCARD_NAME ="SDCard/";


    public FileSystemListenerImpl(  )
    {

    }

    public void rootChanged( int state, String rootName )
    {
        if( state ==  FileSystemListener.ROOT_ADDED)
        {

            if( SDCARD_NAME.equals(rootName))
            {
                _isMicroSDReady=true;
                scheduleApplicationStart();
                removeFileSystemListener(this);
            }
        }
        else if( state == FileSystemListener.ROOT_REMOVED)
        {

        }
    }

 }

这篇关于哪个事件告诉您该装置已成功启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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