当前位置: 首页>>代码示例>>Java>>正文


Java NfcA类代码示例

本文整理汇总了Java中android.nfc.tech.NfcA的典型用法代码示例。如果您正苦于以下问题:Java NfcA类的具体用法?Java NfcA怎么用?Java NfcA使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NfcA类属于android.nfc.tech包,在下文中一共展示了NfcA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setProt

import android.nfc.tech.NfcA; //导入依赖的package包/类
private void setProt(NfcA tag, boolean prot, int authlim) {
    byte[] response = new byte[0];
    try {
        response = tag.transceive(new byte[]{
                (byte) Constants.COMMAND_READ, // COMMAND_READ
                (byte) 0x84    // page address
        });
        if ((response != null)) {  // read always returns 4 pages
            byte[] write = new byte[]{
                    (byte) 0xA2, // COMMAND_WRITE
                    (byte) 38,   // page address
                    (byte) ((response[0] & 0x078) | (prot ? 0x080 : 0x000) | (authlim & 0x007)),
                    response[1], response[2], response[3]  // keep old value for bytes 1-3, you could also simply set them to 0 as they are currently RFU and must always be written as 0 (response[1], response[2], response[3] will contain 0 too as they contain the read RFU value)
            };
            response = tag.transceive(write);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:codlab,项目名称:amiibo,代码行数:21,代码来源:AmiiboCommands.java

示例2: onCreate

import android.nfc.tech.NfcA; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    pendingIntent = PendingIntent.getActivity(
            this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
    IntentFilter mifare = new IntentFilter((NfcAdapter.ACTION_TECH_DISCOVERED));
    filters = new IntentFilter[] { mifare };
    techs = new String[][] { new String[] {NfcA.class.getName() } };
    if(adapter==null)
    {
        adapter = NfcAdapter.getDefaultAdapter(this);
    }

    imageView = (ImageView) findViewById(R.id.imageView);

    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Animation rotation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotation);

            imageView.startAnimation(rotation);
        }
    });
}
 
开发者ID:ThibaudCrespin,项目名称:iBeaconReader,代码行数:27,代码来源:MainActivity.java

示例3: setAuth0

import android.nfc.tech.NfcA; //导入依赖的package包/类
private void setAuth0(NfcA tag, int auth0) {
    byte[] response = new byte[0];
    try {
        response = tag.transceive(new byte[]{
                (byte) Constants.COMMAND_READ, // COMMAND_READ
                (byte) 0x83    // page address
        });
        if ((response != null) && (response.length >= 16)) {  // read always returns 4 pages
            byte[] write = new byte[]{
                    (byte) 0xA2, // COMMAND_WRITE
                    (byte) 37,   // page address
                    response[0], // keep old value for byte 0
                    response[1], // keep old value for byte 1
                    response[2], // keep old value for byte 2
                    (byte) (auth0 & 0x0ff)
            };
            response = tag.transceive(write);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:codlab,项目名称:amiibo,代码行数:23,代码来源:AmiiboCommands.java

示例4: setupForegroundDispatch

import android.nfc.tech.NfcA; //导入依赖的package包/类
public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) {
    final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass());
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0);
    //IntentFilter  = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
    IntentFilter[] filters = new IntentFilter[1];
    String[][] techList = new String[][]{new String[] { NfcA.class.getName()}, new String[] {NfcB.class.getName()}};

    // Notice that this is the same filter as in our manifest.
    filters[0] = new IntentFilter();
    filters[0].addAction(NfcAdapter.ACTION_TAG_DISCOVERED);
    filters[0].addCategory(Intent.CATEGORY_DEFAULT);
    /*
    try {
        filters[0].addDataType(MIME_TEXT_PLAIN);
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("Check your mime type.");
    }
    */

    adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList);
}
 
开发者ID:peterfillmore,项目名称:Check-Paypass-Random-Number,代码行数:24,代码来源:MainActivity.java

示例5: authenticateAmiibo

import android.nfc.tech.NfcA; //导入依赖的package包/类
public static boolean authenticateAmiibo(NfcA tag, byte[] uid) {
    byte[] password = AmiiboMethods.keygen(uid);

    byte[] auth = new byte[]{
            (byte) 0x1B,
            password[0],
            password[1],
            password[2],
            password[3]
    };
    byte[] response = new byte[0];
    try {
        response = tag.transceive(auth);
        return true;
    } catch (IOException e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:codlab,项目名称:amiibo,代码行数:20,代码来源:AmiiboIO.java

示例6: onNewIntent

import android.nfc.tech.NfcA; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
protected void onNewIntent(Intent paramIntent) {
    if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(paramIntent.getAction())) {
        Tag tag = paramIntent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        byte[] uid = paramIntent.getByteArrayExtra(NfcAdapter.EXTRA_ID);


        NfcA ntag215 = NfcA.get(tag);

        if (_stack_controller != null) {
            PopableFragment popable = _stack_controller.head();
            if (popable != null) {
                if (popable instanceof ScanFragment) {
                    ((ScanFragment) popable).tryReadingAmiibo(ntag215, uid);
                } else if (popable instanceof ScanToWriteFragment) {
                    ((ScanToWriteFragment) popable).tryWriteAmiibo(ntag215, uid);
                }
            }
        }
    } else {
        setIntent(paramIntent);
    }
}
 
开发者ID:codlab,项目名称:amiibo,代码行数:24,代码来源:MainActivity.java

示例7: ListenForNFCIntent

import android.nfc.tech.NfcA; //导入依赖的package包/类
private void ListenForNFCIntent(){
	mAdapter = NfcAdapter.getDefaultAdapter(this);
    mPendingIntent = PendingIntent.getActivity(
    		this,
    		0,
    		new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
    		0);
    IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
    filter.addDataScheme("vnd.android.nfc");
    techListsArray = new String[][] { new String[] { NfcA.class.getName() } };
    Intent launchIntent = getIntent();
    if(launchIntent != null && launchIntent.getAction().equals(NfcAdapter.ACTION_TECH_DISCOVERED))
    {
    	onNewIntent(launchIntent);
    }
}
 
开发者ID:BlochsTech,项目名称:BitcoinCardTerminal,代码行数:17,代码来源:MainActivity.java

示例8: onCreate

import android.nfc.tech.NfcA; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
    // setup NFC
    // http://stackoverflow.com/questions/5685946/nfc-broadcastreceiver-problem
    // http://stackoverflow.com/questions/5685770/nfc-intent-get-info-from-the-tag
	// NOTE on devices without NFC, this method call returns NULL
    mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity);
    
    mNfcPendingIntent = PendingIntent.getActivity(mActivity, 0, new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    IntentFilter tech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
    try {
        tech.addDataType("*/*");
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("fail", e);
    }
    mNfcFilters = new IntentFilter[] { tech };
    
    // Mifare Classic are also NfcA, but in contrary to NfcA, MifareClassic support is optional
    // http://developer.android.com/reference/android/nfc/tech/MifareClassic.html
    mNfcTechLists = new String[][] { new String[] { NfcA.class.getName() } };
}
 
开发者ID:protyposis,项目名称:Studentenportal,代码行数:22,代码来源:NfcLogin.java

示例9: setForegroundListener

import android.nfc.tech.NfcA; //导入依赖的package包/类
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()}};
}
 
开发者ID:OlivierGonthier,项目名称:CryptoNFC,代码行数:22,代码来源:MainActivity.java

示例10: onTagDiscovered

import android.nfc.tech.NfcA; //导入依赖的package包/类
@Override
public void onTagDiscovered(Tag tag) {

    remoteTag = NfcA.get(tag);

    try {
        String str = readUID();
        LocalBroadcastManager.getInstance(mContext).sendBroadcast(new Intent("tag-detected"));
    } catch (Exception e) {
        LocalBroadcastManager.getInstance(mContext).sendBroadcast(new Intent("error"));
    }
}
 
开发者ID:cgvwzq,项目名称:cloneuid,代码行数:13,代码来源:MifareListenerUID.java

示例11: onResume

import android.nfc.tech.NfcA; //导入依赖的package包/类
@Override
public void onResume() {
    super.onResume();

    if (nfcAdapter != null) {
        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), KentKartInformationActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
        IntentFilter intentFilter = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);

        nfcAdapter.enableForegroundDispatch(this, pendingIntent, new IntentFilter[]{intentFilter}, new String[][]{new String[]{NfcA.class.getName()}});
    }
}
 
开发者ID:mehmetakiftutuncu,项目名称:MyKentKart,代码行数:12,代码来源:KentKartInformationActivity.java

示例12: setLock

import android.nfc.tech.NfcA; //导入依赖的package包/类
private void setLock(NfcA tag, boolean lock_128_129,
                     boolean lock_112_127,
                     boolean lock_96_111,
                     boolean lock_80_95,
                     boolean lock_64_79,
                     boolean lock_48_63,
                     boolean lock_32_47,
                     boolean lock_16_31) {
    byte[] response = new byte[0];
    try {
        response = tag.transceive(new byte[]{
                (byte) Constants.COMMAND_READ, // COMMAND_READ
                (byte) 0x82    // page address
        });
        byte lock = (byte) ((lock_128_129 ? 1 << 7 : 0)
                + (lock_112_127 ? 1 << 6 : 0)
                + (lock_96_111 ? 1 << 5 : 0)
                + (lock_80_95 ? 1 << 4 : 0)
                + (lock_64_79 ? 1 << 3 : 0)
                + (lock_48_63 ? 1 << 2 : 0)
                + (lock_32_47 ? 1 << 1 : 0)
                + (lock_16_31 ? 1 : 0));
        if ((response != null)) {  // read always returns 4 pages
            byte[] write = new byte[]{
                    (byte) 0xA2, // COMMAND_WRITE
                    (byte) 38,   // page address
                    lock,
                    response[1], response[2], response[3]  // keep old value for bytes 1-3, you could also simply set them to 0 as they are currently RFU and must always be written as 0 (response[1], response[2], response[3] will contain 0 too as they contain the read RFU value)
            };
            response = tag.transceive(write);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:codlab,项目名称:amiibo,代码行数:36,代码来源:AmiiboCommands.java

示例13: onCreate

import android.nfc.tech.NfcA; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_dump_raw);
	// Show the Up button in the action bar.
	setupActionBar();
	
	mAdapter = NfcAdapter.getDefaultAdapter(this);
       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);
    }
	IntentFilter td = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
	mFilters = new IntentFilter[] { ndef, td };

	// Setup a tech list for all NfcF tags
	mTechLists = new String[][] { 
			new String[] { 
					/*NfcV.class.getName(),
					NfcF.class.getName(),*/ 
					NfcA.class.getName(),
					//NfcB.class.getName() 
					} 
			};
	
	txtRaw = (TextView) findViewById(R.id.txtRaw);
}
 
开发者ID:mchro,项目名称:RejsekortReader,代码行数:34,代码来源:DumpRaw.java

示例14: setUpNfcStuff

import android.nfc.tech.NfcA; //导入依赖的package包/类
private void setUpNfcStuff(){
    // intercept all NFC related Intents and redirect them to this activity while this activity is activated and on the front
    // this is called the "foreground dispatch"
    mAdapter = NfcAdapter.getDefaultAdapter(this);
    mPendingIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),0);
    IntentFilter  nfcTech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
    mFilters = new IntentFilter[]{nfcTech};
    mTechLists = new String[][] {
            new String[] { IsoDep.class.getName() },
            {NfcA.class.getName()}
    };
}
 
开发者ID:ueman,项目名称:CampusCardReader,代码行数:14,代码来源:MainActivity.java

示例15: handle

import android.nfc.tech.NfcA; //导入依赖的package包/类
@Override
public Element handle(Tag tag) {
	NfcA nfca = NfcA.get(tag);
	List<AbstractElement> elements = new LinkedList<AbstractElement>();

	elements.add(TextElement.keyValueFrom("sak", "SAK/SEL_RES", Short.toString(nfca.getSak())));
	elements.add(TextElement.keyValueFrom("atqa", "ATQA/SENS_RES",
			SharedStringUtil.byteToHexString(nfca.getAtqa())));

	Element element = new Element("nfca_tech", "NFC-A (ISO 14443-3A) Technology Information");
	element.addChildElements(elements);
	return element;
}
 
开发者ID:ProjectMAXS,项目名称:maxs,代码行数:14,代码来源:NfcAHandler.java


注:本文中的android.nfc.tech.NfcA类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。