How to start one program directly when I power i.MX53

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to start one program directly when I power i.MX53

950 Views
晓敏梅
Contributor II

I have built the android in the i.MX53 successfully. I want to start one program I write directly when I power the board. What should I do?

Labels (2)
0 Kudos
6 Replies

873 Views
tonyzheng
NXP Employee
NXP Employee

Hi,xiaomei

I have find something useful for you as follows:

                                                                        

开机启动服务的关键点是,当android启动完毕后,android会广播一次android.intent.action.BOOT_COMPLETED。如果想在启动后执行自己的代码,需要编写一个广播的接收者,并且注册接收者到这个广播intent上。

这里以android中使用定时任务代码为例,将它的服务改为开机启动。

首先,需要编写一个intent的receiver,比如SmsServiceBootReceiver:

通过这个Receiver,启动SmsService。那么怎么让这个Receiver工作呢,需要把它注册到android系统上,去监听广播的BOOT_COMPLETED intent。在AndroidManifest.xml中:

<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
    package=”com.easymorse” android:versionCode=”1″ android:versionName=”1.0″>
    <application android:icon=”@drawable/icon” android:label=”@string/app_name”>
        <activity android:name=”.SmsServiceOptions” android:label=”@string/app_name”>
            <intent-filter>
                <action android:name=”android.intent.action.MAIN” />
                <category android:name=”android.intent.category.LAUNCHER” />
            </intent-filter>
        </activity>

        <service android:name=”.SmsService”>
            <intent-filter>
                <action android:name=”com.easymorse.SmsService”></action>
            </intent-filter>
        </service>
        <receiver android:name=”SmsServiceBootReceiver”>
            <intent-filter>
                <action android:name=”android.intent.action.BOOT_COMPLETED”></action>
            </intent-filter>
        </receiver>
    </application>
    <uses-sdk android:minSdkVersion=”3″ />
</manifest>

增加黑体字部分的内容即可。

这样重新开机,服务在开机android系统启动完毕后就会加载。再启动Activity绑定(binding)服务,就可以操作SmsService服务,如果Activity解除绑定,也不会shutdown服务了。

                                            

if any problems, pls contact me!

yours,

Tony Zheng

0 Kudos

873 Views
晓敏梅
Contributor II

Thank you for your reply.

But I don't want to start after android is up. I want to start form my program directly.

0 Kudos

873 Views
rickchu
Contributor IV

Do you means start your special program (or shell) like below?

u-boot --> launch kernel --> init.rc --> "your_special_program" --> Android start

Rick

0 Kudos

873 Views
jimmychan
NXP TechSupport
NXP TechSupport

you want to start your program when the u-boot start?

Or you want to start it after the Android is up?

0 Kudos

873 Views
晓敏梅
Contributor II

I want to start my program when the u-boot start rather than the android is up.

0 Kudos

873 Views
jimmychan
NXP TechSupport
NXP TechSupport

you can modify the u-boot source code to run your program directly.

0 Kudos