Is it possible to write an intent object to an NFC tag? For example, if I could write the following intent to an NFC tag:
String phoneNumber = "5555555555";
Uri uri = Uri.parse("sms:" + phoneNumber);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra("address", phoneNumber);
intent.setType("vnd.android-dir/mms-sms");
String intentAsUri = intent.toUri(0);
// = #Intent;action=android.intent.action.VIEW;type=vnd.android-dir/mms-sm开发者_StackOverflow社区s;S.address=5555555555;end
then I could write the output uri as a url data to an NFC tag. When a user taps my tag, android interprets as the above intent, and launches an sms messenger? It doesn't seem to work, and I don't know that there's a way to serialize an intent object itself onto an NFC tag (or that android would know to interpret one)
Thanks
You can write a special URL to invoke SMS app: sms:+tel_no
. There are some issues with adding a body text: see here.
There are multiple types of 'NDEF' defined - most are under the type 'U' URI actions, including subtype 0 (no action) which will allow you to fill the space with whatever and act accordingly in your app. However there is also type 'T' for text actions (but have to work with international codepages as a result).
http://members.nfc-forum.org/specs/spec_list/ as a starting point, but you probably already know this.
精彩评论