Search in sources :

Example 6 with NfcEvent

use of android.nfc.NfcEvent in project i2p.i2p-bote by i2p.

the class ViewIdentityActivity method onCreate.

@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState == null) {
        String key = null;
        Bundle args = getIntent().getExtras();
        if (args != null)
            key = args.getString(ViewIdentityFragment.ADDRESS);
        if (key == null) {
            setResult(RESULT_CANCELED);
            finish();
            return;
        }
        ViewIdentityFragment f = ViewIdentityFragment.newInstance(key);
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, f).commit();
    }
    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (mNfcAdapter != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        mNfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {

            @Override
            public NdefMessage createNdefMessage(NfcEvent nfcEvent) {
                return getNdefMessage();
            }
        }, this);
    }
}
Also used : NfcEvent(android.nfc.NfcEvent) Bundle(android.os.Bundle) NdefMessage(android.nfc.NdefMessage) NfcAdapter(android.nfc.NfcAdapter) SuppressLint(android.annotation.SuppressLint)

Aggregations

NfcAdapter (android.nfc.NfcAdapter)6 NfcEvent (android.nfc.NfcEvent)6 NdefMessage (android.nfc.NdefMessage)4 SuppressLint (android.annotation.SuppressLint)2 TargetApi (android.annotation.TargetApi)2 NdefRecord (android.nfc.NdefRecord)2 CreateBeamUrisCallback (android.nfc.NfcAdapter.CreateBeamUrisCallback)2 Bundle (android.os.Bundle)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1