最近一直遇到这样的问题,为什么我的手机只有自带的程序能够读取到nfc标签但是我自己写的应用却读不到呢?我确定应用应该是没错的
谁能帮我解答解答呢?
这是我的代码:
package zwu.xxh.nfc_demo;
import android.app.Activity;
import android.content.Intent;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.nfc.tech.MifareClassic;
import android.os.Bundle;
import android.widget.TextView;
public class Beam extends Activity {
NfcAdapter nfcAdapter;
TextView promt;
byte a[]={(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
promt = (TextView) findViewById(R.id.promt);
// 获取默认的NFC控制器
nfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (nfcAdapter == null) {
promt.setText("设备不支持NFC!");
finish();
return;
}
if (!nfcAdapter.isEnabled()) {
promt.setText("请在系统设置中先启用NFC功能!");
finish();
return;
}
}
@Override
protected void onResume() {
super.onResume();