4

I have an executable in /system/bin which is compiled from a small C program.

I have root, and can run this executable successfully in Re explorer and Script Manager.

Tried init.d method to auto run this executable during boot, but system stuck at boot logo.So I gave it up.

Now I'm wondering how can I auto run executable after system boot in an easy way since I'm a newbee to Android programming?

P.S. Tried Script Manager to run it as root during boot, but system booted without running it.

sschrass
  • 7,014
  • 6
  • 43
  • 62
Wood
  • 41
  • 1
  • 1
  • 2

2 Answers2

3

You can use /init.rc for that. Just read it and find a suitable place to start your program, add this line there:

start myservice

Then, at the end of this file, define myservice as a service that runs /system/bin/myexecutabe and which is disabled by default (only started when someone issues start command) and is not restarted when it dies (oneshot), like this:

service myservice /system/bin/myexecutable
    disabled
    oneshot
Krzysztof Adamski
  • 2,039
  • 11
  • 14
  • 2
    As described in my answer, "disabled" means that the service won't start automatically. It will only be run if is requested by "start myservice". Normally when service terminates it will be automatically restarted unless y you – Krzysztof Adamski Feb 21 '16 at 14:37
  • 1
    ..unless you specify "oneshot" option. (not sure why this was truncated). – Krzysztof Adamski Feb 22 '16 at 07:20
  • 1
    Sadly, this no longer seems to work, due to SELinux. You need to define an SELinux domain for the service, and add a "seclabel" option. – Edward Falk Apr 03 '19 at 02:49
-2

http://easyrobot.online/temp/permission6.jar

http://easyrobot.online/temp/permission6.jar

        if(!AccessPermission.getPermmission(this)){

            AccessPermission.setOnPermmissionResult(new OnPermmissionResult() {

                @Override
                public void OnPermmission(boolean access, String[] permissions,
                        int[] grantResults) {

    if(access)init();
                }
            });
        }else init();
Alexander
  • 1
  • 1