Java 类android.nfc.NfcEvent 实例源码

项目:buildAPKsSamples    文件:Beam.java   
/**
 * Implementation for the CreateNdefMessageCallback interface
 */
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
    Time time = new Time();
    time.setToNow();
    String text = ("Beam me up!\n\n" +
            "Beam Time: " + time.format("%H:%M:%S"));
    NdefMessage msg = new NdefMessage(NdefRecord.createMime(
            "application/com.example.android.beam", text.getBytes())
     /**
      * The Android Application Record (AAR) is commented out. When a device
      * receives a push with an AAR in it, the application specified in the AAR
      * is guaranteed to run. The AAR overrides the tag dispatch system.
      * You can add it back in to guarantee that this
      * activity starts when receiving a beamed message. For now, this code
      * uses the tag dispatch system.
      */
      //,NdefRecord.createApplicationRecord("com.example.android.beam")
    );
    return msg;
}
项目:Movie-Notifier-Android    文件:WatcherBottomSheet.java   
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    cinemas = DBHelper.getInstance(getContext()).getCinemas();

    watcher = new Gson().fromJson(getArguments().getString("watcher"), Watcher.class);

    nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
    if(nfcAdapter != null) {
        nfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
            @Override
            public NdefMessage createNdefMessage(NfcEvent nfcEvent) {
                return new NdefMessage(
                        new NdefRecord[] {
                                NdefRecord.createUri(BuildConfig.SERVER_BASE_URL + "w/" + watcher.getID()),
                                NdefRecord.createApplicationRecord(BuildConfig.APPLICATION_ID)
                        }
                );
            }
        }, getActivity());
    }
}
项目:AndroidthingsStudy    文件:Beam.java   
/**
 * Implementation for the CreateNdefMessageCallback interface
 */
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
    Time time = new Time();
    time.setToNow();
    String text = ("Beam me up!\n\n" +
            "Beam Time: " + time.format("%H:%M:%S"));
    NdefMessage msg = new NdefMessage(NdefRecord.createMime(
            "application/com.example.android.beam", text.getBytes())
     /**
      * The Android Application Record (AAR) is commented out. When a device
      * receives a push with an AAR in it, the application specified in the AAR
      * is guaranteed to run. The AAR overrides the tag dispatch system.
      * You can add it back in to guarantee that this
      * activity starts when receiving a beamed message. For now, this code
      * uses the tag dispatch system.
      */
      //,NdefRecord.createApplicationRecord("com.example.android.beam")
    );
    return msg;
}
项目:p2p-android-sdk    文件:PeerService.java   
public void registerNfcCallback(Activity activity) {
    NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter != null) {
        // Register callback
        nfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
            @Override
            public NdefMessage createNdefMessage(NfcEvent event) {
                return new NdefMessage(
                    new NdefRecord[] {
                        NdefRecord.createMime(
                            "application/vnd.com.pgrenaud.android.p2p.beam",
                            getPeerRepository().encode().getBytes()
                        )
                    }
                );
            }
        }, activity);

        Log.d("PeerService", "NdefPushMessageCallback registered");
    }
}
项目:py-eventos-android    文件:NfcSenderUtils.java   
public static boolean setAppDataPushMessageCallbackIfAvailable(Activity activity, final CreateNfcAppDataCallback callback) {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity);
    if (adapter == null) {
        return false;
    }
    final String packageName = activity.getPackageName();
    adapter.setNdefPushMessageCallback(new CreateNdefMessageCallback() {

        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            byte[] appData = callback.createNfcAppData();
            if (appData == null) {
                return null;
            }
            NdefRecord[] records = new NdefRecord[] { createMimeRecord("application/" + packageName, appData),
                    NdefRecord.createApplicationRecord(packageName) };
            return new NdefMessage(records);
        }

    }, activity);
    return true;
}
项目:ots15-companion    文件:NfcSenderUtils.java   
public static boolean setAppDataPushMessageCallbackIfAvailable(Activity activity, final CreateNfcAppDataCallback callback) {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity);
    if (adapter == null) {
        return false;
    }
    final String packageName = activity.getPackageName();
    adapter.setNdefPushMessageCallback(new CreateNdefMessageCallback() {

        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            byte[] appData = callback.createNfcAppData();
            if (appData == null) {
                return null;
            }
            NdefRecord[] records = new NdefRecord[]{createMimeRecord("application/" + packageName, appData),
                    NdefRecord.createApplicationRecord(packageName)};
            return new NdefMessage(records);
        }

    }, activity);
    return true;
}
项目:OpenSongTablet    文件:StageMode.java   
@Override
public Uri[] createBeamUris(NfcEvent event) {
    String transferFile = FullscreenActivity.songfilename;
    File extDir;
    if (FullscreenActivity.whichSongFolder.equals(getString(R.string.mainfoldername))) {
        extDir =FullscreenActivity.dir;
    } else {
        extDir = new File(FullscreenActivity.dir + "/" + FullscreenActivity.whichSongFolder + "/");
    }
    File requestFile = new File(extDir, transferFile);
    boolean b = requestFile.setReadable(true, false);
    if (!b) {
        // Get a URI for the File and add it to the list of URIs
        Uri fileUri = Uri.fromFile(requestFile);
        if (fileUri != null) {
            mFileUris[0] = fileUri;
        } else {
            Log.e("My Activity", "No File URI available for file.");
        }
        return mFileUris;
    } else {
        return null;
    }
}
项目:Camera2    文件:CameraActivity.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setupNfcBeamPush() {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mAppContext);
    if (adapter == null) {
        return;
    }

    if (!ApiHelper.HAS_SET_BEAM_PUSH_URIS) {
        // Disable beaming
        adapter.setNdefPushMessage(null, CameraActivity.this);
        return;
    }

    adapter.setBeamPushUris(null, CameraActivity.this);
    adapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() {
        @Override
        public Uri[] createBeamUris(NfcEvent event) {
            return mNfcPushUris;
        }
    }, CameraActivity.this);
}
项目:Icicle    文件:OpenReferenceActivity.java   
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
    return new NdefMessage(
            new NdefRecord[] { NdefRecord.createMime(
                    "application/vnd.co.loubo.icicle", this.encodedNodeRef.getBytes(Charset.forName("US-ASCII")))
                    /**
                     * The Android Application Record (AAR) is commented out. When a device
                     * receives a push with an AAR in it, the application specified in the AAR
                     * is guaranteed to run. The AAR overrides the tag dispatch system.
                     * You can add it back in to guarantee that this
                     * activity starts when receiving a beamed message. For now, this code
                     * uses the tag dispatch system.
                     */
                    //,NdefRecord.createApplicationRecord("com.example.android.beam")
            });
}
项目:rp15    文件:NfcSenderUtils.java   
public static boolean setAppDataPushMessageCallbackIfAvailable(Activity activity, final CreateNfcAppDataCallback callback) {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity);
    if (adapter == null) {
        return false;
    }
    final String packageName = activity.getPackageName();
    adapter.setNdefPushMessageCallback(new CreateNdefMessageCallback() {

        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            byte[] appData = callback.createNfcAppData();
            if (appData == null) {
                return null;
            }
            NdefRecord[] records = new NdefRecord[]{createMimeRecord("application/" + packageName, appData),
                    NdefRecord.createApplicationRecord(packageName)};
            return new NdefMessage(records);
        }

    }, activity);
    return true;
}
项目:Heistr    文件:EditBuildActivity.java   
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
    // NFC should be auto granted, but doesn't hurt to check.
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.NFC)
            != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.NFC}, NFC_PERMISSIONS);
    }

    String url = URLEncoder.encodeBuild(this, currentBuild);
    NdefMessage msg = new NdefMessage(
            new NdefRecord[] { createMime(
                    "application/vnd.com.jamieadkins.heistr", url.getBytes())
                    ,NdefRecord.createApplicationRecord("com.jamieadkins.heistr")
            });
    return msg;
}
项目:AndroidCommunicationBenchmark    文件:NFCServer.java   
@Override
public void start() {
    if (!nfcAdapter.isEnabled())
    {
        this.activity.startActivity(new Intent(Settings.ACTION_NFC_SETTINGS));
        return;
    }

    this.nfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            byte[] payload = new byte[Preferences.getInstance().getPayloadSize()];
            Arrays.fill(payload, (byte) 1);
            return new NdefMessage(
                    new NdefRecord[] { NdefRecord.createMime(
                            MIMETYPE, payload)
                    });
        }
    },this.activity);
}
项目:nexus-camera    文件:CameraActivity.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setupNfcBeamPush() {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(CameraActivity.this);
    if (adapter == null) {
        return;
    }

    if (!ApiHelper.HAS_SET_BEAM_PUSH_URIS) {
        // Disable beaming
        adapter.setNdefPushMessage(null, CameraActivity.this);
        return;
    }

    adapter.setBeamPushUris(null, CameraActivity.this);
    adapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() {
        @Override
        public Uri[] createBeamUris(NfcEvent event) {
            return mNfcPushUris;
        }
    }, CameraActivity.this);
}
项目:Blaubot    文件:BlaubotNFCBeacon.java   
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
    if (currentUri == null) { // || !isStarted) ignore ...
        if (Log.logErrorMessages()) {
            Log.e(LOG_TAG, "I have no URI, can't send NFC message. ");
        }
        return null; // don't provide a message
    }
    if (Log.logDebugMessages()) {
        Log.d(LOG_TAG, "NFC transaction is taking place ...");
    }
    NdefMessage msg = new NdefMessage(
            new NdefRecord[]{
                    NdefRecord.createUri(currentUri)
            });
    return msg;
}
项目:Dingyu    文件:MainTimeLineParentActivity.java   
private void initNFC() {
    NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (mNfcAdapter == null) {
        return;
    }

    mNfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            String text = (GlobalContext.getInstance().getCurrentAccountName());

            NdefMessage msg = new NdefMessage(
                    new NdefRecord[]{createMimeRecord(
                            "application/org.qii.weiciyuan.beam", text.getBytes()), NdefRecord.createApplicationRecord(getPackageName())
                    });
            return msg;
        }
    }, this);

}
项目:Dingyu    文件:AbstractAppActivity.java   
private void initNFC() {
    NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (mNfcAdapter == null) {
        return;
    }

    mNfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            String text = (GlobalContext.getInstance().getCurrentAccountName());

            NdefMessage msg = new NdefMessage(
                    new NdefRecord[]{createMimeRecord(
                            "application/org.qii.weiciyuan.beam", text.getBytes()), NdefRecord.createApplicationRecord(getPackageName())
                    });
            return msg;
        }
    }, this);

}
项目:fosdem-companion-android    文件:NfcUtils.java   
/**
 * Call this method in an Activity, between onCreate() and onDestroy(), to make its content sharable using Android Beam if available. MIME type of the data
 * to share will be "application/" followed by the app's package name. Declare it in your Manifest's intent filters as the data type with an action of
 * android.nfc.action.NDEF_DISCOVERED to handle the NFC Intents on the receiver side.
 *
 * @return true if NFC is available and the content was made available, false if not.
 */
public static boolean setAppDataPushMessageCallbackIfAvailable(Activity activity, final CreateNfcAppDataCallback callback) {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity);
    if (adapter == null) {
        return false;
    }
    final String packageName = activity.getPackageName();
    adapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {

        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            byte[] appData = callback.createNfcAppData();
            if (appData == null) {
                return null;
            }
            NdefRecord[] records = new NdefRecord[]{createMimeRecord("application/" + packageName, appData),
                    NdefRecord.createApplicationRecord(packageName)};
            return new NdefMessage(records);
        }

    }, activity);
    return true;
}
项目:AIRShare    文件:ShaireService.java   
@SuppressLint("NewApi")
public void activateNFCSharing(Activity activity) {
    if (mShAIReHttpServer != null && mShAIReHttpServer.getRealUrl() != null) {
        // NFC
        if (android.os.Build.VERSION.SDK_INT > 14) {
            NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
            if (nfcAdapter != null) {
                nfcAdapter.setNdefPushMessageCallback(
                        new NfcAdapter.CreateNdefMessageCallback() {

                            @Override
                            public NdefMessage createNdefMessage(
                                    NfcEvent event) {
                                return new NdefMessage(
                                        new NdefRecord[]{NdefRecord.createUri(Uri
                                                .parse(mShAIReHttpServer
                                                        .getRealUrl()))});
                            }
                        }, activity);
            }
        }
    }
}
项目:siciyuan    文件:MainTimeLineParentActivity.java   
private void initNFC() {
    NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (mNfcAdapter == null) {
        return;
    }

    mNfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            String text = (GlobalContext.getInstance().getCurrentAccountName());

            NdefMessage msg = new NdefMessage(
                    new NdefRecord[]{createMimeRecord(
                            "application/org.qii.weiciyuan.beam", text.getBytes()),
                            NdefRecord.createApplicationRecord(getPackageName())
                    });
            return msg;
        }
    }, this);
}
项目:siciyuan    文件:AbstractAppActivity.java   
private void initNFC() {
    NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (mNfcAdapter == null) {
        return;
    }

    mNfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            String text = (GlobalContext.getInstance().getCurrentAccountName());

            NdefMessage msg = new NdefMessage(
                    new NdefRecord[]{createMimeRecord(
                            "application/org.qii.weiciyuan.beam", text.getBytes()),
                            NdefRecord.createApplicationRecord(getPackageName())
                    });
            return msg;
        }
    }, this);
}
项目:gdgapp    文件:ArrowActivity.java   
@Override
public NdefMessage createNdefMessage(NfcEvent nfcEvent) {

    try {
        String msg = getEncryptedMessage();
        NdefRecord mimeRecord = new NdefRecord(
                NdefRecord.TNF_MIME_MEDIA,
                Const.ARROW_MIME.getBytes(Charset.forName("US-ASCII")),
                new byte[0],
                msg.getBytes(Charset.forName("US-ASCII")));
        NdefMessage message = new NdefMessage(new NdefRecord[]{mimeRecord});
        return message;
    } catch (Exception e) {
        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        Toast.makeText(ArrowActivity.this, ArrowActivity.this.getString(R.string.arrow_oops), Toast.LENGTH_LONG).show();
    }
    return null;
}
项目:nfc    文件:Beam.java   
/**
 * Implementation for the CreateNdefMessageCallback interface
 */
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
    Time time = new Time();
    time.setToNow();
    String text = ("Beam me up!\n\n" +
            "Beam Time: " + time.format("%H:%M:%S"));
    NdefMessage msg = new NdefMessage(
            new NdefRecord[] { createMimeRecord(
                    "application/edu.cs4730.nfcdemo.beam", text.getBytes())
     /**
      * The Android Application Record (AAR) is commented out. When a device
      * receives a push with an AAR in it, the application specified in the AAR
      * is guaranteed to run. The AAR overrides the tag dispatch system.
      * You can add it back in to guarantee that this
      * activity starts when receiving a beamed message. For now, this code
      * uses the tag dispatch system.
      */
      //,NdefRecord.createApplicationRecord("com.example.android.beam")
    });
    return msg;
}
项目:nfc    文件:MainActivity.java   
/**
 * Implementation for the CreateNdefMessageCallback interface
 */
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
    Time time = new Time();
    time.setToNow();
    String text = ("Beam me up!\n\n" +
        "Beam Time: " + time.format("%H:%M:%S"));
    NdefMessage msg = new NdefMessage(
        new NdefRecord[] { createMimeRecord(
            "application/edu.cs4730.nfcdemo.beam", text.getBytes())
            /**
             * The Android Application Record (AAR) is commented out. When a device
             * receives a push with an AAR in it, the application specified in the AAR
             * is guaranteed to run. The AAR overrides the tag dispatch system.
             * You can add it back in to guarantee that this
             * activity starts when receiving a beamed message. For now, this code
             * uses the tag dispatch system.
            */
            //,NdefRecord.createApplicationRecord("com.example.android.beam")
        });
    return msg;
}
项目:smartedu    文件:AbstractAppActivity.java   
private void initNFC() {
    NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (mNfcAdapter == null) {
        return;
    }

    mNfcAdapter.setNdefPushMessageCallback(
            new NfcAdapter.CreateNdefMessageCallback() {
                @Override
                public NdefMessage createNdefMessage(NfcEvent event) {
                    String text = (GlobalContext.getInstance()
                            .getCurrentAccountName());

                    NdefMessage msg = new NdefMessage(
                            new NdefRecord[] {
                                    createMimeRecord(
                                            "application/com.engc.smartedu.beam",
                                            text.getBytes()),
                                    NdefRecord
                                            .createApplicationRecord(getPackageName()) });
                    return msg;
                }
            }, this);

}
项目:smartedu    文件:MainTitmeLineAppActivity.java   
private void initNFC() {
    NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (mNfcAdapter == null) {
        return;
    }

    mNfcAdapter.setNdefPushMessageCallback(
            new NfcAdapter.CreateNdefMessageCallback() {
                @Override
                public NdefMessage createNdefMessage(NfcEvent event) {
                    String text = (GlobalContext.getInstance()
                            .getCurrentAccountName());

                    NdefMessage msg = new NdefMessage(
                            new NdefRecord[] {
                                    createMimeRecord(
                                            "application/com.engc.smartedu.beam",
                                            text.getBytes()),
                                    NdefRecord
                                            .createApplicationRecord(getPackageName()) });
                    return msg;
                }
            }, this);

}
项目:phimpme-android-v1    文件:UploadActivity.java   
private boolean enable_nfc() {
    nfcTextView.setVisibility(View.VISIBLE);
    NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter != null) {
        // NFC is available on this device
        nfcAdapter.setBeamPushUris(null, this);
        nfcAdapter.setBeamPushUrisCallback(new NfcAdapter.CreateBeamUrisCallback() {
            @Override
            public Uri[] createBeamUris(NfcEvent event) {
                Uri[] nfcPushUris = new Uri[1];
                nfcPushUris[0] = imageUri;
                return nfcPushUris;
            }
        }, this);
        return true;
    } else {
        return false;
    }
}
项目:CSCI567---Workspace    文件:DefaultNfcBeamWriterActivity.java   
/**
 * 
 * Implementation of {@link CreateNdefMessageCallback} interface.
 * 
 * This method is called when another device is within reach (communication is to take place).
 */

@Override
public NdefMessage createNdefMessage(NfcEvent event) {
    Log.d(TAG, "Create message to be beamed");

    // create message to be pushed, for example
    Message message = new Message();
    // add text record
    message.add(new TextRecord("This is my beam text record"));
    // add 'my' external type record
    message.add(new GenericExternalTypeRecord("my.domain", "atype", "My data".getBytes(Charset.forName("UTF-8"))));

    // encode to NdefMessage, will be pushed via beam (now!) (unless there is a collision)
    return message.getNdefMessage();
}
项目:rallye-android-client    文件:NfcCallback.java   
@Override
@TargetApi(14)
public NdefMessage createNdefMessage(NfcEvent event) {
    ObjectMapper mapper = Serialization.getJsonInstance();
    String text = null;
    try {
        text = mapper.writeValueAsString(server.exportLogin());
    } catch (JsonProcessingException e) {
        Log.e(THIS, "Could not export Login", e);
    }
    NdefMessage msg = new NdefMessage(
               new NdefRecord[] {
                    new NdefRecord(
                            NdefRecord.TNF_MIME_MEDIA, Std.APP_MIME.getBytes(Charset.forName("US-ASCII")),
                            new byte[0],
                            text.getBytes(Charset.forName("US_ASCII"))),
                    NdefRecord.createApplicationRecord("de.stadtrallye.rallyesoft")
       });
       return msg;
}
项目:clipboard-beam    文件:MainActivity.java   
@Override
public NdefMessage createNdefMessage(final NfcEvent event) {
    byte[] langBytes = Locale.getDefault().getLanguage()
            .getBytes(Charset.forName("US-ASCII"));
    byte[] textBytes = mEt.getText().toString().trim()
            .getBytes(Charset.forName("UTF-8"));
    char status = (char) (langBytes.length);
    byte[] data = new byte[1 + langBytes.length + textBytes.length];
    data[0] = (byte) status;
    System.arraycopy(langBytes, 0, data, 1, langBytes.length);
    System.arraycopy(textBytes, 0, data, 1 + langBytes.length,
            textBytes.length);

    return new NdefMessage(new NdefRecord[] {
            new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT,
                    new byte[0], data),
            NdefRecord.createApplicationRecord(getPackageName()) });
}
项目:google-iosched    文件:SearchActivity.java   
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void trySetBeamCallback() {
    if (UIUtils.hasICS()) {
        BeamUtils.setBeamCompleteCallback(this, new NfcAdapter.OnNdefPushCompleteCallback() {
            @Override
            public void onNdefPushComplete(NfcEvent event) {
                // Beam has been sent
                if (!BeamUtils.isBeamUnlocked(SearchActivity.this)) {
                    BeamUtils.setBeamUnlocked(SearchActivity.this);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            showFirstBeamDialog();
                        }
                    });
                }
            }
        });
    }
}
项目:google-iosched    文件:SessionsVendorsMultiPaneActivity.java   
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void trySetBeamCallback() {
    if (UIUtils.hasICS()) {
        BeamUtils.setBeamCompleteCallback(this, new NfcAdapter.OnNdefPushCompleteCallback() {
            @Override
            public void onNdefPushComplete(NfcEvent event) {
                // Beam has been sent
                if (!BeamUtils.isBeamUnlocked(SessionsVendorsMultiPaneActivity.this)) {
                    BeamUtils.setBeamUnlocked(SessionsVendorsMultiPaneActivity.this);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            showFirstBeamDialog();
                        }
                    });
                }
            }
        });
    }
}
项目:google-iosched    文件:SessionDetailActivity.java   
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void trySetBeamCallback() {
    if (UIUtils.hasICS()) {
        BeamUtils.setBeamCompleteCallback(this, new NfcAdapter.OnNdefPushCompleteCallback() {
            @Override
            public void onNdefPushComplete(NfcEvent event) {
                // Beam has been sent
                if (!BeamUtils.isBeamUnlocked(SessionDetailActivity.this)) {
                    BeamUtils.setBeamUnlocked(SessionDetailActivity.this);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            showFirstBeamDialog();
                        }
                    });
                }
            }
        });
    }
}
项目:chromium-for-android-56-debug-video    文件:BeamCallback.java   
@Override
public void onNdefPushComplete(NfcEvent event) {
    if (mErrorRunnableIfBeamSent != null) {
        Handler h = new Handler(Looper.getMainLooper());
        h.postDelayed(mErrorRunnableIfBeamSent, TOAST_ERROR_DELAY_MS);
        mErrorRunnableIfBeamSent = null;
    }
}
项目:buildAPKsSamples    文件:Beam.java   
/**
 * Implementation for the OnNdefPushCompleteCallback interface
 */
@Override
public void onNdefPushComplete(NfcEvent arg0) {
    // A handler is needed to send messages to the activity when this
    // callback occurs, because it happens from a binder thread
    mHandler.obtainMessage(MESSAGE_SENT).sendToTarget();
}
项目:Movie-Notifier-Android    文件:WatcherBottomSheet.java   
private void dismissalTask() {
    if(nfcAdapter != null && getActivity() != null && !getActivity().isFinishing()) {
        nfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
            @Override
            public NdefMessage createNdefMessage(NfcEvent nfcEvent) {
                return new NdefMessage(
                        new NdefRecord[] {
                                NdefRecord.createUri("https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID + "&feature=beam"),
                                NdefRecord.createUri(BuildConfig.APPLICATION_ID)
                        }
                );
            }
        }, getActivity()); // Don't keep sharing this watcher when the sheet is dismissed, return something similar to Android Beam default
    }
}
项目:okwallet    文件:RequestCoinsFragment.java   
@Override
public NdefMessage createNdefMessage(final NfcEvent event) {
    final byte[] paymentRequest = paymentRequestRef.get();
    if (paymentRequest != null)
        return new NdefMessage(
                new NdefRecord[] { Nfc.createMime(PaymentProtocol.MIMETYPE_PAYMENTREQUEST, paymentRequest) });
    else
        return null;
}
项目:okwallet    文件:WalletAddressFragment.java   
@Override
public NdefMessage createNdefMessage(final NfcEvent event) {
    final String uri = currentAddressUriRef.get();
    if (uri != null)
        return new NdefMessage(new NdefRecord[] { NdefRecord.createUri(uri) });
    else
        return null;
}
项目:AndroidthingsStudy    文件:Beam.java   
/**
 * Implementation for the OnNdefPushCompleteCallback interface
 */
@Override
public void onNdefPushComplete(NfcEvent arg0) {
    // A handler is needed to send messages to the activity when this
    // callback occurs, because it happens from a binder thread
    mHandler.obtainMessage(MESSAGE_SENT).sendToTarget();
}
项目:TenguChat    文件:XmppActivity.java   
protected void registerNdefPushMessageCallback() {
    NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter != null && nfcAdapter.isEnabled()) {
        nfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
            @Override
            public NdefMessage createNdefMessage(NfcEvent nfcEvent) {
                return new NdefMessage(new NdefRecord[]{
                        NdefRecord.createUri(getShareableUri()),
                        NdefRecord.createApplicationRecord("de.tengu.chat")
                });
            }
        }, this);
    }
}
项目:messengerxmpp    文件:XmppActivity.java   
protected void registerNdefPushMessageCallback() {
    NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter != null && nfcAdapter.isEnabled()) {
        nfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
            @Override
            public NdefMessage createNdefMessage(NfcEvent nfcEvent) {
                return new NdefMessage(new NdefRecord[]{
                    NdefRecord.createUri(getShareableUri()),
                        NdefRecord.createApplicationRecord("eu.siacs.conversations")
                });
            }
        }, this);
    }
}