I want to make an application which has auto start option in its settings. I have made Settings activity in my application which is derived from PreferenceActivity and give CheckBoxPreference for auto start option. If auto start option is enabled my application should start when booting of phone is completed. And if auto start option is disabled then it should not start on boot completed.
To achieve this I have implemented derived class of BroadcastReceiver which receives BOOT_COMPLETED intent, declare receiver in AndroidManifest.xml and also give permission in AndroidManifest.xml.
In application also there is a derived class of Application and start service also from the onCreate method of application derived class. If I declare receiver in AndroidManifest.xml then after booting completed onCreate of my application called and after that onReceive method of BroadcastReceiver called.
Now the problem is that my application starts on boot completed every time whether auto start is enabled or disabled. Is it possible to not start application when auto start is disabled ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…