Loading core/java/android/nfc/NfcAdapter.java +31 −42 Original line number Original line Diff line number Diff line Loading @@ -91,8 +91,7 @@ public final class NfcAdapter { * <meta-data android:name="android.nfc.action.TECH_DISCOVERED" * <meta-data android:name="android.nfc.action.TECH_DISCOVERED" * android:resource="@xml/filter_nfc" * android:resource="@xml/filter_nfc" * /> * /> * </activity> * </activity></pre> * </pre> * * * <p>The meta-data XML file should contain one or more <code>tech-list</code> entries * <p>The meta-data XML file should contain one or more <code>tech-list</code> entries * each consisting or one or more <code>tech</code> entries. The <code>tech</code> entries refer * each consisting or one or more <code>tech</code> entries. The <code>tech</code> entries refer Loading Loading @@ -121,8 +120,7 @@ public final class NfcAdapter { * <tech>android.nfc.tech.MifareClassic</tech> * <tech>android.nfc.tech.MifareClassic</tech> * <tech>android.nfc.tech.Ndef</tech> * <tech>android.nfc.tech.Ndef</tech> * </tech-list> * </tech-list> * </resources> * </resources></pre> * </pre> * * * <p>This intent is started after {@link #ACTION_NDEF_DISCOVERED} and before * <p>This intent is started after {@link #ACTION_NDEF_DISCOVERED} and before * {@link #ACTION_TAG_DISCOVERED}. If any activities respond to {@link #ACTION_NDEF_DISCOVERED} * {@link #ACTION_TAG_DISCOVERED}. If any activities respond to {@link #ACTION_NDEF_DISCOVERED} Loading Loading @@ -385,10 +383,9 @@ public final class NfcAdapter { * Most Android devices will only have one NFC Adapter (NFC Controller). * Most Android devices will only have one NFC Adapter (NFC Controller). * <p> * <p> * This helper is the equivalent of: * This helper is the equivalent of: * <pre>{@code * <pre> * NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE); * NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE); * NfcAdapter adapter = manager.getDefaultAdapter(); * NfcAdapter adapter = manager.getDefaultAdapter();</pre> * }</pre> * @param context the calling application's context * @param context the calling application's context * * * @return the default NFC adapter, or null if no NFC adapter exists * @return the default NFC adapter, or null if no NFC adapter exists Loading Loading @@ -623,8 +620,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setBeamPushUris(new Uri[] {uri1, uri2}, this); * nfcAdapter.setBeamPushUris(new Uri[] {uri1, uri2}, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the Uri(s) and the * OS will automatically release its references to the Uri(s) and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -704,8 +700,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setBeamPushUrisCallback(callback, this); * nfcAdapter.setBeamPushUrisCallback(callback, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the Uri(s) and the * OS will automatically release its references to the Uri(s) and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -758,14 +753,13 @@ public final class NfcAdapter { * * * <p>If you want to prevent the Android OS from sending default NDEF * <p>If you want to prevent the Android OS from sending default NDEF * messages completely (for all activities), you can include a * messages completely (for all activities), you can include a * <code><meta-data></code> element inside the <code><application></code> * {@code <meta-data>} element inside the {@code <application>} * element of your AndroidManifest.xml file, like this: * element of your AndroidManifest.xml file, like this: * <pre>{@code * <pre> * <application ...> * <application ...> * <meta-data android:name="android.nfc.disable_beam_default" * <meta-data android:name="android.nfc.disable_beam_default" * android:value="true" /> * android:value="true" /> * </application> * </application></pre> * }</pre> * * * <p>The API allows for multiple activities to be specified at a time, * <p>The API allows for multiple activities to be specified at a time, * but it is strongly recommended to just register one at a time, * but it is strongly recommended to just register one at a time, Loading @@ -776,8 +770,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setNdefPushMessage(ndefMessage, this); * nfcAdapter.setNdefPushMessage(ndefMessage, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the NDEF message and the * OS will automatically release its references to the NDEF message and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -857,14 +850,13 @@ public final class NfcAdapter { * * * <p>If you want to prevent the Android OS from sending default NDEF * <p>If you want to prevent the Android OS from sending default NDEF * messages completely (for all activities), you can include a * messages completely (for all activities), you can include a * <code><meta-data></code> element inside the <code><application></code> * {@code <meta-data>} element inside the {@code <application>} * element of your AndroidManifest.xml file, like this: * element of your AndroidManifest.xml file, like this: * <pre>{@code * <pre> * <application ...> * <application ...> * <meta-data android:name="android.nfc.disable_beam_default" * <meta-data android:name="android.nfc.disable_beam_default" * android:value="true" /> * android:value="true" /> * </application> * </application></pre> * }</pre> * * * <p>The API allows for multiple activities to be specified at a time, * <p>The API allows for multiple activities to be specified at a time, * but it is strongly recommended to just register one at a time, * but it is strongly recommended to just register one at a time, Loading @@ -875,8 +867,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setNdefPushMessageCallback(callback, this); * nfcAdapter.setNdefPushMessageCallback(callback, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the callback and the * OS will automatically release its references to the callback and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -941,8 +932,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setOnNdefPushCompleteCallback(callback, this); * nfcAdapter.setOnNdefPushCompleteCallback(callback, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the callback and the * OS will automatically release its references to the callback and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -1190,8 +1180,7 @@ public final class NfcAdapter { * } else if (!nfcAdapter.isNdefPushEnabled()) { * } else if (!nfcAdapter.isNdefPushEnabled()) { * startActivity(new Intent(Settings.ACTION_NFCSHARING_SETTINGS)); * startActivity(new Intent(Settings.ACTION_NFCSHARING_SETTINGS)); * } * } * } * }</pre> * </pre> * * * @see android.provider.Settings#ACTION_NFCSHARING_SETTINGS * @see android.provider.Settings#ACTION_NFCSHARING_SETTINGS * @return true if NDEF Push feature is enabled * @return true if NDEF Push feature is enabled Loading Loading
core/java/android/nfc/NfcAdapter.java +31 −42 Original line number Original line Diff line number Diff line Loading @@ -91,8 +91,7 @@ public final class NfcAdapter { * <meta-data android:name="android.nfc.action.TECH_DISCOVERED" * <meta-data android:name="android.nfc.action.TECH_DISCOVERED" * android:resource="@xml/filter_nfc" * android:resource="@xml/filter_nfc" * /> * /> * </activity> * </activity></pre> * </pre> * * * <p>The meta-data XML file should contain one or more <code>tech-list</code> entries * <p>The meta-data XML file should contain one or more <code>tech-list</code> entries * each consisting or one or more <code>tech</code> entries. The <code>tech</code> entries refer * each consisting or one or more <code>tech</code> entries. The <code>tech</code> entries refer Loading Loading @@ -121,8 +120,7 @@ public final class NfcAdapter { * <tech>android.nfc.tech.MifareClassic</tech> * <tech>android.nfc.tech.MifareClassic</tech> * <tech>android.nfc.tech.Ndef</tech> * <tech>android.nfc.tech.Ndef</tech> * </tech-list> * </tech-list> * </resources> * </resources></pre> * </pre> * * * <p>This intent is started after {@link #ACTION_NDEF_DISCOVERED} and before * <p>This intent is started after {@link #ACTION_NDEF_DISCOVERED} and before * {@link #ACTION_TAG_DISCOVERED}. If any activities respond to {@link #ACTION_NDEF_DISCOVERED} * {@link #ACTION_TAG_DISCOVERED}. If any activities respond to {@link #ACTION_NDEF_DISCOVERED} Loading Loading @@ -385,10 +383,9 @@ public final class NfcAdapter { * Most Android devices will only have one NFC Adapter (NFC Controller). * Most Android devices will only have one NFC Adapter (NFC Controller). * <p> * <p> * This helper is the equivalent of: * This helper is the equivalent of: * <pre>{@code * <pre> * NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE); * NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE); * NfcAdapter adapter = manager.getDefaultAdapter(); * NfcAdapter adapter = manager.getDefaultAdapter();</pre> * }</pre> * @param context the calling application's context * @param context the calling application's context * * * @return the default NFC adapter, or null if no NFC adapter exists * @return the default NFC adapter, or null if no NFC adapter exists Loading Loading @@ -623,8 +620,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setBeamPushUris(new Uri[] {uri1, uri2}, this); * nfcAdapter.setBeamPushUris(new Uri[] {uri1, uri2}, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the Uri(s) and the * OS will automatically release its references to the Uri(s) and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -704,8 +700,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setBeamPushUrisCallback(callback, this); * nfcAdapter.setBeamPushUrisCallback(callback, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the Uri(s) and the * OS will automatically release its references to the Uri(s) and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -758,14 +753,13 @@ public final class NfcAdapter { * * * <p>If you want to prevent the Android OS from sending default NDEF * <p>If you want to prevent the Android OS from sending default NDEF * messages completely (for all activities), you can include a * messages completely (for all activities), you can include a * <code><meta-data></code> element inside the <code><application></code> * {@code <meta-data>} element inside the {@code <application>} * element of your AndroidManifest.xml file, like this: * element of your AndroidManifest.xml file, like this: * <pre>{@code * <pre> * <application ...> * <application ...> * <meta-data android:name="android.nfc.disable_beam_default" * <meta-data android:name="android.nfc.disable_beam_default" * android:value="true" /> * android:value="true" /> * </application> * </application></pre> * }</pre> * * * <p>The API allows for multiple activities to be specified at a time, * <p>The API allows for multiple activities to be specified at a time, * but it is strongly recommended to just register one at a time, * but it is strongly recommended to just register one at a time, Loading @@ -776,8 +770,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setNdefPushMessage(ndefMessage, this); * nfcAdapter.setNdefPushMessage(ndefMessage, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the NDEF message and the * OS will automatically release its references to the NDEF message and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -857,14 +850,13 @@ public final class NfcAdapter { * * * <p>If you want to prevent the Android OS from sending default NDEF * <p>If you want to prevent the Android OS from sending default NDEF * messages completely (for all activities), you can include a * messages completely (for all activities), you can include a * <code><meta-data></code> element inside the <code><application></code> * {@code <meta-data>} element inside the {@code <application>} * element of your AndroidManifest.xml file, like this: * element of your AndroidManifest.xml file, like this: * <pre>{@code * <pre> * <application ...> * <application ...> * <meta-data android:name="android.nfc.disable_beam_default" * <meta-data android:name="android.nfc.disable_beam_default" * android:value="true" /> * android:value="true" /> * </application> * </application></pre> * }</pre> * * * <p>The API allows for multiple activities to be specified at a time, * <p>The API allows for multiple activities to be specified at a time, * but it is strongly recommended to just register one at a time, * but it is strongly recommended to just register one at a time, Loading @@ -875,8 +867,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setNdefPushMessageCallback(callback, this); * nfcAdapter.setNdefPushMessageCallback(callback, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the callback and the * OS will automatically release its references to the callback and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -941,8 +932,7 @@ public final class NfcAdapter { * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); * if (nfcAdapter == null) return; // NFC not available on this device * if (nfcAdapter == null) return; // NFC not available on this device * nfcAdapter.setOnNdefPushCompleteCallback(callback, this); * nfcAdapter.setOnNdefPushCompleteCallback(callback, this); * } * }</pre> * </pre> * And that is it. Only one call per activity is necessary. The Android * And that is it. Only one call per activity is necessary. The Android * OS will automatically release its references to the callback and the * OS will automatically release its references to the callback and the * Activity object when it is destroyed if you follow this pattern. * Activity object when it is destroyed if you follow this pattern. Loading Loading @@ -1190,8 +1180,7 @@ public final class NfcAdapter { * } else if (!nfcAdapter.isNdefPushEnabled()) { * } else if (!nfcAdapter.isNdefPushEnabled()) { * startActivity(new Intent(Settings.ACTION_NFCSHARING_SETTINGS)); * startActivity(new Intent(Settings.ACTION_NFCSHARING_SETTINGS)); * } * } * } * }</pre> * </pre> * * * @see android.provider.Settings#ACTION_NFCSHARING_SETTINGS * @see android.provider.Settings#ACTION_NFCSHARING_SETTINGS * @return true if NDEF Push feature is enabled * @return true if NDEF Push feature is enabled Loading