コード例 #1
0
ファイル: NfcAdapter.java プロジェクト: BvbKoala/SourceCode
 /**
  * Enable NDEF message push over NFC while this Activity is in the foreground.
  *
  * <p>You must explicitly call this method every time the activity is resumed, and you must call
  * {@link #disableForegroundNdefPush} before your activity completes {@link Activity#onPause}.
  *
  * <p>Strongly recommend to use the new {@link #setNdefPushMessage} instead: it automatically
  * hooks into your activity life-cycle, so you do not need to call enable/disable in your
  * onResume/onPause.
  *
  * <p>For NDEF push to function properly the other NFC device must support either NFC Forum's SNEP
  * (Simple Ndef Exchange Protocol), or Android's "com.android.npp" (Ndef Push Protocol). This was
  * optional on Gingerbread level Android NFC devices, but SNEP is mandatory on Ice-Cream-Sandwich
  * and beyond.
  *
  * <p>This method must be called from the main thread.
  *
  * <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
  *
  * @param activity foreground activity
  * @param message a NDEF Message to push over NFC
  * @throws IllegalStateException if the activity is not currently in the foreground
  * @deprecated use {@link #setNdefPushMessage} instead
  */
 @Deprecated
 public void enableForegroundNdefPush(Activity activity, NdefMessage message) {
   if (activity == null || message == null) {
     throw new NullPointerException();
   }
   enforceResumed(activity);
   mNfcActivityManager.setNdefPushMessage(activity, message);
 }
コード例 #2
0
ファイル: NfcAdapter.java プロジェクト: BvbKoala/SourceCode
 /**
  * Disable NDEF message push over P2P.
  *
  * <p>After calling {@link #enableForegroundNdefPush}, an activity must call this method before
  * its {@link Activity#onPause} callback completes.
  *
  * <p>Strongly recommend to use the new {@link #setNdefPushMessage} instead: it automatically
  * hooks into your activity life-cycle, so you do not need to call enable/disable in your
  * onResume/onPause.
  *
  * <p>This method must be called from the main thread.
  *
  * <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
  *
  * @param activity the Foreground activity
  * @throws IllegalStateException if the Activity has already been paused
  * @deprecated use {@link #setNdefPushMessage} instead
  */
 public void disableForegroundNdefPush(Activity activity) {
   if (activity == null) {
     throw new NullPointerException();
   }
   enforceResumed(activity);
   mNfcActivityManager.setNdefPushMessage(activity, null);
   mNfcActivityManager.setNdefPushMessageCallback(activity, null);
   mNfcActivityManager.setOnNdefPushCompleteCallback(activity, null);
 }
コード例 #3
0
ファイル: NfcAdapter.java プロジェクト: BvbKoala/SourceCode
 /**
  * TODO: Remove this once pre-built apk's (Maps, Youtube etc) are updated
  *
  * @deprecated use {@link #setNdefPushMessageCallback} instead
  * @hide
  */
 @Deprecated
 public void enableForegroundNdefPush(Activity activity, final NdefPushCallback callback) {
   if (activity == null || callback == null) {
     throw new NullPointerException();
   }
   enforceResumed(activity);
   LegacyCallbackWrapper callbackWrapper = new LegacyCallbackWrapper(callback);
   mNfcActivityManager.setNdefPushMessageCallback(activity, callbackWrapper);
   mNfcActivityManager.setOnNdefPushCompleteCallback(activity, callbackWrapper);
 }