-1

I have made an apk that allows the user to edit kernel's configuration and to make these changes sticky also after a reboot I have added the scripts that the app copies into init.d folder. Now the problem is that the scripts are very much and I'm thinking about making a bootservice that applies the user's preferences at boot, simply executing commands at boot avoiding the scripts and so saving space.

Can someone explain to me what I have to do?

Archlight
  • 2,019
  • 2
  • 21
  • 34
mascIT
  • 413
  • 4
  • 16
  • possible duplicate of [How to get a script in init.d to execute on boot in Android?](http://stackoverflow.com/questions/5464713/how-to-get-a-script-in-init-d-to-execute-on-boot-in-android) – 323go Mar 06 '14 at 14:08

2 Answers2

1

You need to create a service that will listen to "android.intent.action.BOOT_COMPLETED" Broadcast Intent. Take in mind that you starting from Android 3.0 you need to run your application at least one time to be able to catch this event.

For example, you may read this article to understand what you need to do.

Yury
  • 20,618
  • 7
  • 58
  • 86
  • More, look into the answer to this question: http://stackoverflow.com/questions/5051687/broadcastreceiver-not-receiving-boot-completed – Yury Mar 06 '14 at 14:08
0

Write BroadcastReceiver which will get called when the device is booted.

public class BootCompleteReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
        //do your stuffs here

    }
  }
}

Register BroadcastReceiver in manifest.xml:

<receiver android:name="packageName.BootCompleteReceiver " >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
</receiver>

Add required permission to the manifest.xml:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Green goblin
  • 9,898
  • 13
  • 71
  • 100