3

So I'm starting to get into Android development, but I'm not fully aware of all the possibilities yet.

For my first bigger project I want to make an application that allows me to track my traveling with the push of a button. Another button will cancel the trip and calculate the traveled distance for me. I figured I could use Google Maps API for this.

I need to use this app every day for it to be effective, but this is something that could easily be forgotten.

TL;DR: Is there a possibility I can activate a specific function in my app by putting an RFID tag in my car and putting my phone on top of it. When it comes off, the functionality will also stop.

Keep in mind, this needs to be done when my phone screen is off, so use it more as a service.

Storyboad:

  1. Get in car
  2. Put phone on RFID tag
  3. Start tracking
  4. Take phone off RFID tag
  5. Stop tracking trip and calculate travel distance
  6. Get out car
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
Jordec
  • 1,516
  • 2
  • 22
  • 43

2 Answers2

0

It is possible you would need to create a background service that detects the RFID and check from time to time. Although this is only achievable when the app is open or in the background

Mike
  • 1,313
  • 12
  • 21
  • Do you think this is possible when the phone is in standby? I have concerns about security issues for this. – Jordec Feb 15 '17 at 10:48
  • By standby you mean screen is on or off? As long as the app is in the background it is very much possible. – Mike Feb 15 '17 at 10:52
  • I prefer to have my screen off. The idea is to put my phone where I always put it and it would activate. This is to prevent I forgot to activate it when I'm in my car. – Jordec Feb 15 '17 at 11:52
  • Yup it is very much possible, A good example is an app playing an audio even if your screen is off. For as long as the app is open and in the background. – Mike Feb 15 '17 at 12:33
  • I just read that due to security reason, NFC is turned off when the phone screen is off. But I suppose I can get the same result with bluetooth. – Jordec Feb 15 '17 at 12:36
  • 1
    Well you could still run it on background. BLE would be a good try since it has a bigger range – Mike Feb 15 '17 at 13:05
  • This is simply wrong since background services can't interact with the NFC reader functionality of Android. – Michael Roland Feb 15 '17 at 14:32
0

When you refer to RFID as the NFC functionality included many Android phones, then the answer is no. Android devices will not scan for (or even communicate with) NFC tags while their screen is turned off. In fact, communication with tags will even be interrupted if the screen turns of while reading a tag.

Also, Android devices will typically not even scan for tags while the screen is on and locked (except when smart lock is used with an NFC tag).

However, you may be able to change that behavior by using (or creating) a customized Android ROM or by using Xposed on a rooted device (see for instance this Xposed module.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206