My question is not a duplicate: I have searched SO and on the web and haven't found a definite answer yet.
In a bluetooth-related app I would like a background Service
to be started on device boot and then connect to a bluetooth beacon (if available) and post Android notifications to the user on certain events.
So I have added following lines to AndroidManifest.xml
:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<service
android:name="ScanService"
android:icon="@drawable/ic_launcher">
<intent-filter>
<category android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</service>
However Eclipse displays the warning Exported receiver does not require permission which probably means, that any app could run my service. And of course I don't want that.
I want only the Android OS (at the boot time) and my MainActivity (acting as settings GUI-frontend to the background service) being able to do (re)start the ScanService.
There are 2 common suggestions for this problem:
- First is to add android:exported="false" to the intent filter.
- Second is to add android:permission to the intent filter.
But I still have follow-up questions please:
- Will
BOOT_COMPLETED
broadcast still be delivered to the "non-exported" service? - What permission to specify here, is it really
RECEIVE_BOOT_COMPLETE
or something else (and does Android-system needs this permission?)