How to send NFC intent?

371 views
Skip to first unread message

Dan Sulik

unread,
Nov 12, 2015, 7:57:02 AM11/12/15
to DroidScript
Hi,

1. Can anyone help on how to send intent to open NFC settings and/or enable NFC if phone supports it?
2. Is there a list of package and class names for intents?
3 .Is there a way to check NFC is available?

Thank you
Dan

Chris Hopkin

unread,
Nov 13, 2015, 5:19:21 AM11/13/15
to DroidScript
Hi Dan

It may be possible to open the NFC settings page using an intent in a similar way as described in this post:


However, it does require finding out the required classname. A search on stackoverflow.com may help here.

It is worth noting that this will be easier in the next version of DroidScript, where app.SendIntent doesn't require packagename or classname. This will allow certain activities to be launched by just providing the action parameter. For example, the action "android.settings.NFC_SETTINGS" can be used to launch the NFC settings page.

As for checking if NFC is available - there is no way at the moment to check this in DroidScript. Please post your interest in this on the 'Tell us what you want' thread.

Thanks

Chris

Dan Sulik

unread,
Nov 30, 2015, 9:20:41 AM11/30/15
to DroidScript
Hi Chris,

please can you help out with this.
I have not found a way how to find classname.
The following code does not do anything

sendIntent( "com.android.settings", "com.android.settings.nfc.NfcSettings" );

Thank you
Dan

Chris Hopkin

unread,
Nov 30, 2015, 10:26:44 AM11/30/15
to DroidScript
Hi Dan

I've had a quick search but I'm not able to find a suitable NFC settings related class to use with SendIntent.

However, I can open the NFC settings page using the latest private beta version of DroidScript, simply using the android.settings.NFC_SETTINGS action (all other SendIntent parameters can be null).

If you'd like to become part of the private beta tester group and get hold of the improved SendIntent functionality, please send an email to Dave Smart.

Thanks

Chris

Dan Sulik

unread,
Nov 30, 2015, 1:41:47 PM11/30/15
to DroidScript
Hi Chris,

please how can I reach Dave. Where to find his email? I am interested in trying out beta version.

Thank you
Dan

Steve Garman

unread,
Nov 30, 2015, 2:06:52 PM11/30/15
to DroidScript
It is difficult to paste email addresses here, I have emailed Dave's address to Dan.

If anyone else is looking for it, go to the DroidScript app in Google Play and click on the Developer Email link.

Alternatively, find one of his posts in this group and select "Reply privately to author". This option requires the desktop version of the webpage.

Dan Sulik

unread,
Dec 3, 2015, 2:06:41 PM12/3/15
to DroidScript
The followng code works well in DS 1.31b

function OpenNFCSettings()
{
    app.SendIntent( null, null, "android.settings.NFC_SETTINGS", null, null, null, null);
}


Do you know if thre is a way to enable NFC without going to NFC settings?

Thank you 
Dan

Chris Hopkin

unread,
Dec 4, 2015, 9:14:41 AM12/4/15
to DroidScript
Hi Dan

I'm not aware of any way of enabling/disabling NFC programmatically (on non-rooted devices anyway). I think you will have to send the user to the NFC settings to enable it manually.

Thanks

Chris 
Reply all
Reply to author
Forward
0 new messages