I'm curious if Android NFC service
allows the developer to start a Service
(or IntentService
for that matter) when NFC
tag is scanned?
From Android Developers:
When a device scans a tag that has
NDEF
data on it, but could not be mapped to aMIME
orURI
, the tag dispatch system tries to start an activity with theACTION_TECH_DISCOVERED
intent.
It appears that only a new Activity can be launched, not Service, although it could receive the same Intent filter.
Although not the direct method, you could have a barebones Activity
that will immediately start a service, then quit:
@Override
public void onCreate(Bundle savedInstanceState) {
Context con = getApplicationContext();
Intent srv = new Intent(con, TargetService.class);
con.startService(srv);
finish();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With