Java 类android.nfc.tech.NfcF 实例源码

项目:CryptoNFC    文件:MainActivity.java   
private void setForegroundListener() {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean handleFormatable = preferences.getBoolean("format_ndef_formatable_tags", false);

    pi = PendingIntent.getActivity(this, 0, new Intent(this,getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
    intentFiltersArray = null;
    if(handleFormatable)
        techList = new String[][]{ new String[]{ NfcA.class.getName(),Ndef.class.getName()},
                new String[]{ NfcB.class.getName(),Ndef.class.getName()},
                new String[]{ NfcF.class.getName(),Ndef.class.getName()},
                new String[]{ NfcV.class.getName(),Ndef.class.getName()},
                new String[]{ NfcA.class.getName(),NdefFormatable.class.getName()},
                new String[]{ NfcB.class.getName(),NdefFormatable.class.getName()},
                new String[]{ NfcF.class.getName(),NdefFormatable.class.getName()},
                new String[]{ NfcV.class.getName(),NdefFormatable.class.getName()}};
    else
        techList = new String[][]{ new String[]{ NfcA.class.getName(),Ndef.class.getName()},
                new String[]{ NfcB.class.getName(),Ndef.class.getName()},
                new String[]{ NfcF.class.getName(),Ndef.class.getName()},
                new String[]{ NfcV.class.getName(),Ndef.class.getName()}};
}
项目:phonk    文件:AppRunnerActivity.java   
public void initializeNFC() {

        if (nfcInit == false) {
            PackageManager pm = getPackageManager();
            nfcSupported = pm.hasSystemFeature(PackageManager.FEATURE_NFC);

            if (nfcSupported == false) {
                return;
            }

            // when is in foreground
            MLog.d(TAG, "starting NFC");
            mAdapter = NfcAdapter.getDefaultAdapter(this);

            // PedingIntent will be delivered to this activity
            mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

            // Setup an intent filter for all MIME based dispatches
            IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
            try {
                ndef.addDataType("*/*");
            } catch (IntentFilter.MalformedMimeTypeException e) {
                throw new RuntimeException("fail", e);
            }
            mFilters = new IntentFilter[]{ ndef, };

            // Setup a tech list for all NfcF tags
            mTechLists = new String[][]{new String[]{NfcF.class.getName()}};
            nfcInit = true;
        }
    }
项目:AndroidthingsStudy    文件:ForegroundDispatch.java   
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    setContentView(R.layout.foreground_dispatch);
    mText = (TextView) findViewById(R.id.text);
    mText.setText("Scan a tag");

    mAdapter = NfcAdapter.getDefaultAdapter(this);

    // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
    // will fill in the intent with the details of the discovered tag before delivering to
    // this activity.
    mPendingIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    // Setup an intent filter for all MIME based dispatches
    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndef.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("fail", e);
    }
    mFilters = new IntentFilter[] {
            ndef,
    };

    // Setup a tech list for all NfcF tags
    mTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
项目:anroid-nfc-plugin    文件:ScanActivity.java   
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Create NFC Adapter
    mAdapter = NfcAdapter.getDefaultAdapter(this);

    // Pending intent
    mPendingIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, ScanActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    // Setup an intent filter for all MIME based dispatches (TEXT);
    IntentFilter ndefText = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndefText.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
    }       

    // Setup an intent filter for all MIME based dispatches (URI);
    IntentFilter ndefURI = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    ndefURI.addDataScheme("http");
    ndefURI.addDataScheme("https");

    mFilters = new IntentFilter[] { ndefText, ndefURI}; 

    // Setup a tech list for all NfcF tags
    mTechLists = new String[][] { new String[] { NfcF.class.getName() } };          
}
项目:ApkLauncher    文件:ForegroundDispatch.java   
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    setContentView(R.layout.foreground_dispatch);
    mText = (TextView) findViewById(R.id.text);
    mText.setText("Scan a tag");

    mAdapter = NfcAdapter.getDefaultAdapter(this);

    // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
    // will fill in the intent with the details of the discovered tag before delivering to
    // this activity.
    mPendingIntent = org.bbs.apklauncher.emb.PendingIntentHelper.getActivity(this, 0,
            new org.bbs.apklauncher.emb.IntentHelper(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    // Setup an intent filter for all MIME based dispatches
    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndef.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("fail", e);
    }
    mFilters = new IntentFilter[] {
            ndef,
    };

    // Setup a tech list for all NfcF tags
    mTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
项目:nfcard    文件:FelicaReader.java   
static void readCard(NfcF tech, Card card) throws IOException {

        final FeliCa.Tag tag = new FeliCa.Tag(tech);

        tag.connect();

        /*
         * 
        FeliCa.SystemCode systems[] = tag.getSystemCodeList();
        if (systems.length == 0) {
            systems = new FeliCa.SystemCode[] { new FeliCa.SystemCode(
                    tag.getSystemCodeByte()) };
        }

        for (final FeliCa.SystemCode sys : systems)
            card.addApplication(readApplication(tag, sys.toInt()));
        */

        // better old card compatibility 
        card.addApplication(readApplication(tag, SYS_OCTOPUS));

        try {
            card.addApplication(readApplication(tag, SYS_SZT));
        } catch (IOException e) {
            // for early version of OCTOPUS which will throw shit
        }

        tag.close();
    }
项目:ApiDemos    文件:ForegroundDispatch.java   
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    setContentView(R.layout.foreground_dispatch);
    mText = (TextView) findViewById(R.id.text);
    mText.setText("Scan a tag");

    mAdapter = NfcAdapter.getDefaultAdapter(this);

    // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
    // will fill in the intent with the details of the discovered tag before delivering to
    // this activity.
    mPendingIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    // Setup an intent filter for all MIME based dispatches
    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndef.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("fail", e);
    }
    mFilters = new IntentFilter[] {
            ndef,
    };

    // Setup a tech list for all NfcF tags
    mTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
项目:NFCard    文件:FelicaReader.java   
static void readCard(NfcF tech, Card card) throws IOException {

        final FeliCa.Tag tag = new FeliCa.Tag(tech);

        tag.connect();

        /*
         * 
        FeliCa.SystemCode systems[] = tag.getSystemCodeList();
        if (systems.length == 0) {
            systems = new FeliCa.SystemCode[] { new FeliCa.SystemCode(
                    tag.getSystemCodeByte()) };
        }

        for (final FeliCa.SystemCode sys : systems)
            card.addApplication(readApplication(tag, sys.toInt()));
        */

        // better old card compatibility 
        card.addApplication(readApplication(tag, SYS_OCTOPUS));

        try {
            card.addApplication(readApplication(tag, SYS_SZT));
        } catch (IOException e) {
            // for early version of OCTOPUS which will throw shit
        }

        tag.close();
    }
项目:felix-on-android    文件:ForegroundDispatch.java   
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    setContentView(R.layout.foreground_dispatch);
    mText = (TextView) findViewById(R.id.text);
    mText.setText("Scan a tag");

    mAdapter = NfcAdapter.getDefaultAdapter(this);

    // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
    // will fill in the intent with the details of the discovered tag before delivering to
    // this activity.
    mPendingIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    // Setup an intent filter for all MIME based dispatches
    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndef.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("fail", e);
    }
    mFilters = new IntentFilter[] {
            ndef,
    };

    // Setup a tech list for all NfcF tags
    mTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
项目:MEng    文件:ForegroundDispatch.java   
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    setContentView(R.layout.foreground_dispatch);
    mText = (TextView) findViewById(R.id.text);
    mText.setText("Scan a tag");

    mAdapter = NfcAdapter.getDefaultAdapter(this);

    // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
    // will fill in the intent with the details of the discovered tag before delivering to
    // this activity.
    mPendingIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    // Setup an intent filter for all MIME based dispatches
    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndef.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("fail", e);
    }
    mFilters = new IntentFilter[] {
            ndef,
    };

    // Setup a tech list for all NfcF tags
    mTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
项目:codeexamples-android    文件:ForegroundDispatch.java   
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    setContentView(R.layout.foreground_dispatch);
    mText = (TextView) findViewById(R.id.text);
    mText.setText("Scan a tag");

    mAdapter = NfcAdapter.getDefaultAdapter(this);

    // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
    // will fill in the intent with the details of the discovered tag before delivering to
    // this activity.
    mPendingIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    // Setup an intent filter for all MIME based dispatches
    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndef.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("fail", e);
    }
    mFilters = new IntentFilter[] {
            ndef,
    };

    // Setup a tech list for all NfcF tags
    mTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
项目:deview-2013-samples    文件:ForegroundDispatch.java   
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    setContentView(R.layout.foreground_dispatch);
    mText = (TextView) findViewById(R.id.text);
    mText.setText("Scan a tag");

    mAdapter = NfcAdapter.getDefaultAdapter(this);

    // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
    // will fill in the intent with the details of the discovered tag before delivering to
    // this activity.
    mPendingIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    // Setup an intent filter for all MIME based dispatches
    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndef.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("fail", e);
    }
    mFilters = new IntentFilter[] {
            ndef,
    };

    // Setup a tech list for all NfcF tags
    mTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
项目:anroid-nfc-plugin    文件:ScanNFCActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set full screen
    setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);      
    getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // Get layout id
    int layoutID = getResources().getIdentifier("activity_scan_nfc", "layout", getPackageName());

    // Load layout
    RelativeLayout layout = (RelativeLayout) LayoutInflater.from(this).inflate(layoutID, null);

    // Set layout as content view
    setContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));


    // Create NFC Adapter
    mAdapter = NfcAdapter.getDefaultAdapter(this);

    if (mAdapter == null) {
        finishWithResult("NO_HARDWARE");
        return;
    }

    // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
    // will fill in the intent with the details of the discovered tag before delivering to
    // this activity.
    mPendingIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, ScanNFCActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    // Setup an intent filter for all MIME based dispatches (TEXT);
    IntentFilter ndefText = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndefText.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
        finishWithResult("ERROR");
        return;
    }       

    // Setup an intent filter for all MIME based dispatches (URI);
    IntentFilter ndefURI = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    ndefURI.addDataScheme("http");
    ndefURI.addDataScheme("https");

    mFilters = new IntentFilter[] { ndefText, ndefURI};

    // Setup a tech list for all NfcF tags
    mTechLists = new String[][] { new String[] { NfcF.class.getName() } };    

}
项目:nfcard    文件:FeliCa.java   
public Tag(NfcF tag) {
    nfcTag = tag;
    sys = tag.getSystemCode();
    idm = new IDm(tag.getTag().getId());
    pmm = new PMm(tag.getManufacturer());
}
项目:FrontOne    文件:OctopusCard.java   
static String load(NfcF tech, Resources res) {
    final FeliCa.Tag tag = new FeliCa.Tag(tech);

    /*--------------------------------------------------------------*/
    // check card system
    /*--------------------------------------------------------------*/

    final int system = tag.getSystemCode();
    final FeliCa.ServiceCode service;
    if (system == SYS_OCTOPUS)
        service = new FeliCa.ServiceCode(SRV_OCTOPUS);
    else if (system == SYS_SZT)
        service = new FeliCa.ServiceCode(SRV_SZT);
    else
        return null;

    tag.connect();

    /*--------------------------------------------------------------*/
    // read service data without encryption
    /*--------------------------------------------------------------*/

    final float[] data = new float[] { 0, 0, 0 };
    final int N = data.length;

    int p = 0;
    for (byte i = 0; p < N; ++i) {
        final FeliCa.ReadResponse r = tag.readWithoutEncryption(service, i);
        if (!r.isOkey())
            break;

        data[p++] = (Util.toInt(r.getBlockData(), 0, 4) - 350) / 10.0f;
    }

    tag.close();

    /*--------------------------------------------------------------*/
    // build result string
    /*--------------------------------------------------------------*/

    final String name = parseName(system, res);
    final String info = parseInfo(tag, res);
    final String hist = parseLog(null, res);
    final String cash = parseBalance(data, p, res);

    return CardManager.buildResult(name, info, cash, hist);
}
项目:FrontOne    文件:CardManager.java   
public static String load(Parcelable parcelable, Resources res) {
    final Tag tag = (Tag) parcelable;


    final IsoDep isodep = IsoDep.get(tag);


    Log.d("NFCTAG", "ffff");//isodep.transceive("45".getBytes()).toString());


    if (isodep != null) {
        return PbocCard.load(isodep, res);
    }

    final NfcV nfcv = NfcV.get(tag);
    if (nfcv != null) {
        return VicinityCard.load(nfcv, res);
    }

    final NfcF nfcf = NfcF.get(tag);
    if (nfcf != null) {
        return OctopusCard.load(nfcf, res);
    }

    return null;
}
项目:FrontOne    文件:FeliCa.java   
public Tag(NfcF tag) {
    nfcTag = tag;
    sys = SystemCode.toInt(tag.getSystemCode());
    idm = new IDm(tag.getTag().getId());
    pmm = new PMm(tag.getManufacturer());
}
项目:NFCard    文件:FeliCa.java   
public Tag(NfcF tag) {
    nfcTag = tag;
    sys = tag.getSystemCode();
    idm = new IDm(tag.getTag().getId());
    pmm = new PMm(tag.getManufacturer());
}
项目:timelapse-sony    文件:NFCHandler.java   
public static String[][] getTechListArray() {
    return new String[][]{new String[]{NfcF.class.getName()}};
}
项目:nfcard    文件:ReaderManager.java   
private Card readCard(Tag tag) {

        final Card card = new Card();

        try {

            publishProgress(SPEC.EVENT.READING);

            card.setProperty(SPEC.PROP.ID, Util.toHexString(tag.getId()));

            final IsoDep isodep = IsoDep.get(tag);
            if (isodep != null)
                StandardPboc.readCard(isodep, card);

            final NfcF nfcf = NfcF.get(tag);
            if (nfcf != null)
                FelicaReader.readCard(nfcf, card);

            publishProgress(SPEC.EVENT.IDLE);

        } catch (Exception e) {
            card.setProperty(SPEC.PROP.EXCEPTION, e);
            publishProgress(SPEC.EVENT.ERROR);
        }

        return card;
    }
项目:NFCard    文件:ReaderManager.java   
private Card readCard(Tag tag) {

        final Card card = new Card();

        try {

            publishProgress(SPEC.EVENT.READING);

            card.setProperty(SPEC.PROP.ID, Util.toHexString(tag.getId()));

            final IsoDep isodep = IsoDep.get(tag);
            if (isodep != null)
                StandardPboc.readCard(isodep, card);

            final NfcF nfcf = NfcF.get(tag);
            if (nfcf != null)
                FelicaReader.readCard(nfcf, card);

            publishProgress(SPEC.EVENT.IDLE);

        } catch (Exception e) {
            card.setProperty(SPEC.PROP.EXCEPTION, e);
            publishProgress(SPEC.EVENT.ERROR);
        }

        return card;
    }