@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //you have to start the service once. startService(new Intent(MainActivity.this, Service1.class)); } }
private DaemonConfigurations createDaemonConfigurations(){ DaemonConfigurations.DaemonConfiguration configuration1 = new DaemonConfigurations.DaemonConfiguration( "com.marswin89.marsdaemon.demo:process1", Service1.class.getCanonicalName(), Receiver1.class.getCanonicalName()); DaemonConfigurations.DaemonConfiguration configuration2 = new DaemonConfigurations.DaemonConfiguration( "com.marswin89.marsdaemon.demo:process2", Service2.class.getCanonicalName(), Receiver2.class.getCanonicalName()); DaemonConfigurations.DaemonListener listener = new MyDaemonListener(); //return new DaemonConfigurations(configuration1, configuration2);//listener can be null return new DaemonConfigurations(configuration1, configuration2, listener); }
/** * give the configuration to lib in this callback * @return */ @Override protected DaemonConfigurations getDaemonConfigurations() { DaemonConfigurations.DaemonConfiguration configuration1 = new DaemonConfigurations.DaemonConfiguration( "com.marswin89.marsdaemon.demo:process1", Service1.class.getCanonicalName(), Receiver1.class.getCanonicalName()); DaemonConfigurations.DaemonConfiguration configuration2 = new DaemonConfigurations.DaemonConfiguration( "com.marswin89.marsdaemon.demo:process2", Service2.class.getCanonicalName(), Receiver2.class.getCanonicalName()); DaemonConfigurations.DaemonListener listener = new MyDaemonListener(); //return new DaemonConfigurations(configuration1, configuration2);//listener can be null return new DaemonConfigurations(configuration1, configuration2, listener); }
@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); mDaemonClient = new DaemonClient(createDaemonConfigurations()); mDaemonClient.onAttachBaseContext(base); }