Execute Script on Boot Android Things

2019-08-26 07:11发布

问题:

I am developing with raspberry pi3 on Android Things. I am trying to execute a Script on boot, modifying init.rc file as so:

sys.boot_completed = 1:

on property: sys.boot_completed = 1

bootchart stop

# WLD 201805031702

chmod +x /system/bin/myScript.sh //Added by me

sh /system/bin/myScript.sh      //Added by me

I don't know why, but the Script doesn't get execute, i have tried to change "hostname anyName" instead of executing the Script on these lines of init.rc file, and it does pass throw these lines because hostname get changes, but it doesn't execute the Script. How can i execute a Script on Boot, i don't know what to do.

Best regards

Alvaro

回答1:

With Android Things, you can set up your application so that it fits within the Android framework.

For example, if you use the HOME intent filter on your main activity in your app, then your activity will launch immediately on boot, allowing you to run some code.