Trigger action on smartphone while in pocket (Android)



  • Hi all!
    Very short summary of my idea:
    Keep your smart phone in the pocket. Touch the pocket with your NFC ring. Let the phone do whatever you want :)

    More Details:
    Since over a year ago, I don't use my Key anymore to get into my home, because I use a combination of smart phone and raspberry pi to switch on my existing door opener (buzzer) from outside the door. But this isn't the idea which I wanted to tell you about.
    Since I found the nfc ring kickstarter, I wanted to open my door with the ring too, like John showed us in his videos, but without changing the door physically (i.e. with existing mechanismns).
    With my existing solution, I need to take my phone out of my pocket, then open an app, wait until it is connected, and then push the button, which controls the relay of the buzzer, and then, the door is open.
    My idea to make this process shorter: Keep phone in pocket, touch with the NFC ring from outside, door's open.

    The intention of this post is to share my progress with you all, because there were a few hurdles on the way.
    First, there is the requirement, that the phone keeps NFC on while the screen is off.
    My solution to it is right now: exposed framework(requires root) with the NFC LockScreenOnEnabler app.

    After this problem was solved, I could move on to my idea:
    To be a little bit more specific: I wanted to do an action (activate the door buzzer) while the NFC tag is still in range of the phone's antenna.
    The state right now is:
    I can start an app with the first touch of a tag and then the second tap activates an action iside the app.
    I'm using the 'foreground dispatching' of android to catch the tag and to connect to it. And now it can be polled, if it is still connected.
    The next problem came up: If the screen is off the foreground dispatching is disabled, but if the screen is on, then you can push unwanted things on the phone, because it is still in the pocket.
    Solution: use the proximity sensor, which turns the screen "off" (the same mechanism, while a phone call when you put the phone on your ear).
    This keeps the activity active and the foreground dispatching enabled but the touch input is inactive.
    Next step was, to close the activity after the action is done (maybe after a few seconds delay that you can trigger the action again).
    But now we have the situation that the screen stays on if the activity releases the proximity sensor and to my surprise it is not easily possible to lock the screen programatically. At least not, without the device admin functionality. I don't know since which android version it exists, but it seems to provide more security relevant permissions for an app.
    So here is the result of my experiments with it, an example eclipse project for android which uses the described mechanisms:
    https://dl.dropboxusercontent.com/u/79648979/nfc/NFCTesto.zip
    In this example, you can scan a tag while the activity is open, then the "action" right now is the vibration alert of the phone, and then after removing the tag, the screen will be locked again and the activity closes itself. To start the app by a seperate first scan of a tag, you can start it by another app (e.g. NFC retag or similar). Once it started, it will unlock the screen by itself. (But you can add an intent filter with a NDEF action to start the app directly).
    I hope this idea / example is useful to someone or someone can create other ideas out of it :)


  • Community Helper

    sound really cool! Thanks for sharing and keep on going


Log in to reply
 

Looks like your connection to NFC Ring Forum was lost, please wait while we try to reconnect.