Search in sources :

Example 1 with CreateBeamUrisCallback

use of android.nfc.NfcAdapter.CreateBeamUrisCallback in project android_packages_apps_Gallery2 by LineageOS.

the class PhotoPage method setupNfcBeamPush.

@TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
private void setupNfcBeamPush() {
    if (!ApiHelper.HAS_SET_BEAM_PUSH_URIS)
        return;
    try {
        NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mActivity);
        if (adapter != null) {
            adapter.setBeamPushUris(null, mActivity);
            adapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() {

                @Override
                public Uri[] createBeamUris(NfcEvent event) {
                    return mNfcPushUris;
                }
            }, mActivity);
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : NfcEvent(android.nfc.NfcEvent) NfcAdapter(android.nfc.NfcAdapter) CreateBeamUrisCallback(android.nfc.NfcAdapter.CreateBeamUrisCallback) ActivityNotFoundException(android.content.ActivityNotFoundException) TargetApi(android.annotation.TargetApi)

Example 2 with CreateBeamUrisCallback

use of android.nfc.NfcAdapter.CreateBeamUrisCallback in project android_packages_apps_Snap by LineageOS.

the class CameraActivity method setupNfcBeamPush.

@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);
}
Also used : NfcEvent(android.nfc.NfcEvent) NfcAdapter(android.nfc.NfcAdapter) CreateBeamUrisCallback(android.nfc.NfcAdapter.CreateBeamUrisCallback) TargetApi(android.annotation.TargetApi)

Aggregations

TargetApi (android.annotation.TargetApi)2 NfcAdapter (android.nfc.NfcAdapter)2 CreateBeamUrisCallback (android.nfc.NfcAdapter.CreateBeamUrisCallback)2 NfcEvent (android.nfc.NfcEvent)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1