android.nfc.NfcEvent Java Examples
The following examples show how to use
android.nfc.NfcEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CameraActivity.java From Camera2 with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: BeamCallback.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onNdefPushComplete(NfcEvent event) { if (mErrorRunnableIfBeamSent != null) { Handler h = new Handler(Looper.getMainLooper()); h.postDelayed(mErrorRunnableIfBeamSent, TOAST_ERROR_DELAY_MS); mErrorRunnableIfBeamSent = null; } }
Example #3
Source File: InvoiceActivity.java From android-sdk with MIT License | 5 votes |
@Override public NdefMessage createNdefMessage(NfcEvent event) { if (mInvoice != null && mInvoice.getPaymentUrls() != null && mInvoice.getPaymentUrls().getBIP72b() != null) { return new NdefMessage(new NdefRecord[]{ NdefRecord.createUri(mInvoice.getPaymentUrls().getBIP72()) }); } return null; }
Example #4
Source File: NfcBeamWriterActivity.java From effective_android_sample with Apache License 2.0 | 5 votes |
@Override public void onNdefPushComplete(NfcEvent nfcEvent) { Log.d(TAG, "Ndef push completed"); runOnUiThread(new Runnable() { public void run() { onNdefPushCompleted(); } }); }
Example #5
Source File: ActivitySendIdentityByNfc.java From ploggy with GNU General Public License v3.0 | 5 votes |
@Override public NdefMessage createNdefMessage(NfcEvent event) { try { String payload = Json.toJson(Data.getInstance().getSelf().mPublicIdentity); return new NdefMessage( new NdefRecord[] { NdefRecord.createMime(NFC_MIME_TYPE, payload.getBytes()), NdefRecord.createApplicationRecord(NFC_AAR_PACKAGE_NAME) }); } catch (Utils.ApplicationError e) { Log.addEntry(LOG_TAG, "failed to create outbound NFC message"); } return null; }
Example #6
Source File: BeamLargeFilesFragment.java From connectivity-samples with Apache License 2.0 | 5 votes |
/** * Callback for Beam events (large file version). The return value here should be an array of * content:// or file:// URIs to send. * * Note that the system must have read access to whatever URIs are provided here. * * @param nfcEvent NFC event which triggered callback * @return URIs to be sent to remote device */ // BEGIN_INCLUDE(createBeamUris) @Override public Uri[] createBeamUris(NfcEvent nfcEvent) { Log.i(TAG, "Beam event in progress; createBeamUris() called."); // Images are served using a content:// URI. See AssetProvider for implementation. Uri photoUri = Uri.parse(CONTENT_BASE_URI + FILENAME); Log.i(TAG, "Sending URI: " + photoUri); return new Uri[] {photoUri}; }
Example #7
Source File: BaseActivity.java From Slide with GNU General Public License v3.0 | 5 votes |
@Override public NdefMessage createNdefMessage(NfcEvent event) { if (shareUrl != null) { return new NdefMessage(new NdefRecord[]{ NdefRecord.createUri(shareUrl) }); } return null; }
Example #8
Source File: BeamCallback.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onNdefPushComplete(NfcEvent event) { if (mErrorRunnableIfBeamSent != null) { Handler h = new Handler(Looper.getMainLooper()); h.postDelayed(mErrorRunnableIfBeamSent, TOAST_ERROR_DELAY_MS); mErrorRunnableIfBeamSent = null; } }
Example #9
Source File: BeamLargeFilesFragment.java From android-BeamLargeFiles with Apache License 2.0 | 5 votes |
/** * Callback for Beam events (large file version). The return value here should be an array of * content:// or file:// URIs to send. * * Note that the system must have read access to whatever URIs are provided here. * * @param nfcEvent NFC event which triggered callback * @return URIs to be sent to remote device */ // BEGIN_INCLUDE(createBeamUris) @Override public Uri[] createBeamUris(NfcEvent nfcEvent) { Log.i(TAG, "Beam event in progress; createBeamUris() called."); // Images are served using a content:// URI. See AssetProvider for implementation. Uri photoUri = Uri.parse(CONTENT_BASE_URI + FILENAME); Log.i(TAG, "Sending URI: " + photoUri); return new Uri[] {photoUri}; }
Example #10
Source File: BeamCallback.java From delion with Apache License 2.0 | 5 votes |
@Override public void onNdefPushComplete(NfcEvent event) { if (mErrorRunnableIfBeamSent != null) { Handler h = new Handler(Looper.getMainLooper()); h.postDelayed(mErrorRunnableIfBeamSent, TOAST_ERROR_DELAY_MS); mErrorRunnableIfBeamSent = null; } }
Example #11
Source File: BeamActivity.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
private void setBeamMessage() { NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); nfcAdapter.setNdefPushMessageCallback( new NfcAdapter.CreateNdefMessageCallback() { public NdefMessage createNdefMessage(NfcEvent event) { String payload = "Beam me up, Android!\n\n" + "Beam Time: " + System.currentTimeMillis(); NdefMessage message = createMessage(payload); return message; } }, this); }
Example #12
Source File: ActivitySendIdentityByNfc.java From ploggy with GNU General Public License v3.0 | 5 votes |
@Override public void onNdefPushComplete(NfcEvent nfcEvent) { final Context finalContext = this; runOnUiThread(new Runnable() { @Override public void run() { Vibrator vibe = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); vibe.vibrate(100); Toast.makeText(finalContext, R.string.prompt_nfc_push_complete, Toast.LENGTH_LONG).show(); }}); }
Example #13
Source File: GpsDataListActivity.java From geopaparazzi with GNU General Public License v3.0 | 5 votes |
@Override public NdefMessage createNdefMessage(NfcEvent event) { try { List<LogMapItem> logsList = DaoGpsLog.getGpslogs(); SerializableLogs logs = new SerializableLogs(); for (int i = 0; i < logsList.size(); i++) { LogMapItem logMapItem = logsList.get(i); if (logMapItem.isVisible()) { Line line = DaoGpsLog.getGpslogAsLine(logMapItem.getLogID(), -1); logs.addLog(logMapItem, line); } } byte[] logBytes = Utilities.serializeObject(logs); NdefMessage msg = new NdefMessage(NdefRecord.createMime( logSendingMimeType, logBytes) /** * 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.examples.nfcbeam") ); return msg; } catch (IOException e) { GPLog.error(this, "Error in sending logs.", e);//NON-NLS } return null; }
Example #14
Source File: GpsDataListActivity.java From geopaparazzi with GNU General Public License v3.0 | 5 votes |
@Override public void onNdefPushComplete(NfcEvent event) { //This callback happens on a binder thread, don't update // the UI directly from this method. runOnUiThread(new Runnable() { @Override public void run() { GPDialogs.infoDialog(GpsDataListActivity.this, getString(R.string.logs_sent), null); } }); }
Example #15
Source File: BaseActivity.java From Slide with GNU General Public License v3.0 | 4 votes |
@Override public void onNdefPushComplete(NfcEvent arg0) { }
Example #16
Source File: InvoiceActivity.java From android-sdk with MIT License | 4 votes |
@Override public void onNdefPushComplete(NfcEvent event) { // Pass }
Example #17
Source File: ExportActivity.java From geopaparazzi with GNU General Public License v3.0 | 4 votes |
@Override public Uri[] createBeamUris(NfcEvent nfcEvent) { GPLog.addLogEntry(this, "URI SENT: " + mFileUris[0]); //NON-NLS return mFileUris; }
Example #18
Source File: MorphingFragment.java From droid-stealth with GNU General Public License v2.0 | 4 votes |
@Override public Uri[] createBeamUris(NfcEvent nfcEvent) { return new Uri[] { Uri.fromFile(mCurrentApp) }; }
Example #19
Source File: MainActivity.java From android-nfc-lib with MIT License | 4 votes |
@Override public NdefMessage createNdefMessage(NfcEvent event) { return new NfcMessageUtilityImpl().createText("Message to beam"); }
Example #20
Source File: AddFriendQRActivity.java From NaviBee with GNU General Public License v3.0 | 4 votes |
@Override public void onNdefPushComplete(NfcEvent event) { }
Example #21
Source File: AddFriendQRActivity.java From NaviBee with GNU General Public License v3.0 | 4 votes |
@Override public NdefMessage createNdefMessage(NfcEvent event) { //When creating an NdefMessage we need to provide an NdefRecord[] return new NdefMessage(createRecords()); }
Example #22
Source File: ProfileManagerActivity.java From Maying with Apache License 2.0 | 4 votes |
@Override public NdefMessage createNdefMessage(NfcEvent nfcEvent) { return new NdefMessage(new NdefRecord[]{new NdefRecord(NdefRecord.TNF_ABSOLUTE_URI, nfcShareItem, new byte[]{}, nfcShareItem)}); }
Example #23
Source File: ProfileManagerActivity.java From ShadowsocksRR with Apache License 2.0 | 4 votes |
@Override public NdefMessage createNdefMessage(NfcEvent nfcEvent) { return new NdefMessage(new NdefRecord[]{new NdefRecord(NdefRecord.TNF_ABSOLUTE_URI, nfcShareItem, new byte[]{}, nfcShareItem)}); }
Example #24
Source File: NfcActivity.java From android-nfc-lib with MIT License | 2 votes |
/** * Method called when attempting to beam. * * @param event * delivered by system * * @return an NFC Message to auto-pair bluetooth, or Test text when no bluetooth is present. */ @Override public NdefMessage createNdefMessage(NfcEvent event) { return new NfcMessageUtilityImpl().createText("You're seeing this message because you have not overridden the createNdefMessage(NfcEvent event) in your activity."); }