diff options
author | Nick Pelly <npelly@google.com> | 2011-08-22 22:27:11 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2011-08-26 17:28:45 -0700 |
commit | c84c89a6cacaf16c1ba41f57cc1aecdb150e85f9 (patch) | |
tree | f3521ac470b3f5785500797fe12af193ab320ced /api | |
parent | 359ef7985316397564a6a999d77f6cc1edab7373 (diff) | |
download | frameworks_base-c84c89a6cacaf16c1ba41f57cc1aecdb150e85f9.zip frameworks_base-c84c89a6cacaf16c1ba41f57cc1aecdb150e85f9.tar.gz frameworks_base-c84c89a6cacaf16c1ba41f57cc1aecdb150e85f9.tar.bz2 |
Improve NDEF push API
Introduce
setNdefPushMessage()
setNdefPushMessageCallback()
setNdefPushCompleteCallback()
Deprecate public API
enableForegroundNdefPush()
disableForegroundNdefPush()
Hide & Deprecate staged (public but never released) API
enableForegroundNdefPushCallback()
The new API's do not require the application to explicitly call
enable()/disable() in onPause()/onResume(), we use a Fragment behind
the scenes to manager this automatically.
NDEF Push can be disabled by using a null parameter, so each
enable()/disable() pair is collapsed to a single set() call.
Application code should now look something like:
public void onCreate() {
NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
if (adapter != null) { // check that NFC is available on this device
adapter.setNdefPushMessage(myNdefMessage, this);
}
}
And that's it - no need to explicitly hook into onPause() and onResume() events.
Also - introduce a generic NfcEvent class that is provided as a parameter on
all NFC callbacks. Right now it just provides the NfcAdapter, but using
the wrapper classes allows us to add more fields later without changing
the callback signature. (i'm thinking Bluetooth).
Change-Id: I371dcb026b535b8199225c1262eca64ce644458a
Diffstat (limited to 'api')
-rw-r--r-- | api/current.txt | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/api/current.txt b/api/current.txt index 01b07a6..a086959 100644 --- a/api/current.txt +++ b/api/current.txt @@ -12412,13 +12412,15 @@ package android.nfc { public final class NfcAdapter { method public void disableForegroundDispatch(android.app.Activity); - method public void disableForegroundNdefPush(android.app.Activity); + method public deprecated void disableForegroundNdefPush(android.app.Activity); method public void enableForegroundDispatch(android.app.Activity, android.app.PendingIntent, android.content.IntentFilter[], java.lang.String[][]); - method public void enableForegroundNdefPush(android.app.Activity, android.nfc.NdefMessage); - method public void enableForegroundNdefPush(android.app.Activity, android.nfc.NfcAdapter.NdefPushCallback); + method public deprecated void enableForegroundNdefPush(android.app.Activity, android.nfc.NdefMessage); method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context); method public static deprecated android.nfc.NfcAdapter getDefaultAdapter(); method public boolean isEnabled(); + method public void setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity...); + method public void setNdefPushMessageCallback(android.nfc.NfcAdapter.CreateNdefMessageCallback, android.app.Activity...); + method public void setOnNdefPushCompleteCallback(android.nfc.NfcAdapter.OnNdefPushCompleteCallback, android.app.Activity...); field public static final java.lang.String ACTION_NDEF_DISCOVERED = "android.nfc.action.NDEF_DISCOVERED"; field public static final java.lang.String ACTION_TAG_DISCOVERED = "android.nfc.action.TAG_DISCOVERED"; field public static final java.lang.String ACTION_TECH_DISCOVERED = "android.nfc.action.TECH_DISCOVERED"; @@ -12427,9 +12429,16 @@ package android.nfc { field public static final java.lang.String EXTRA_TAG = "android.nfc.extra.TAG"; } - public static abstract interface NfcAdapter.NdefPushCallback { - method public abstract android.nfc.NdefMessage createMessage(); - method public abstract void onMessagePushed(); + public static abstract interface NfcAdapter.CreateNdefMessageCallback { + method public abstract android.nfc.NdefMessage createNdefMessage(android.nfc.NfcEvent); + } + + public static abstract interface NfcAdapter.OnNdefPushCompleteCallback { + method public abstract void onNdefPushComplete(android.nfc.NfcEvent); + } + + public final class NfcEvent { + field public final android.nfc.NfcAdapter nfcAdapter; } public final class NfcManager { |