小编noo*_*v98的帖子

当我尝试写入 NFC 标签时,出现标签丢失异常

我希望有人能告诉我我在这里缺少什么。也许这就是我的联系方式。我的标签实际上是 Mifare Ultralight,所以我没有弄错。我调试了,连接到标签成功 - 一切看起来都很好。但日志继续说:

android.nfc.TagLostException:标签丢失。

public class MainActivity extends Activity {

    NfcAdapter mNfcAdapter;
    TextView displayInfo;
    Tag mNfcTag;
    NdefMessage mNdefMessage;

    IntentFilter [] intentFiltersArray;

    String [] [] techListsArray;

    PendingIntent pendingIntent;


    String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
        displayInfo = (TextView) findViewById(R.id.displayInfo);

        NdefRecord application = NdefRecord.createApplicationRecord("com.studios.nfcdemo");


        Locale locale = new Locale("en");

        NdefRecord textText = createTextRecord("pleaseWork", locale, true);

        mNdefMessage = new NdefMessage(textText);

        pendingIntent = PendingIntent.getActivity(
                this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

        IntentFilter ndef = new …
Run Code Online (Sandbox Code Playgroud)

tags android nfc mifare

5
推荐指数
1
解决办法
4410
查看次数

标签 统计

android ×1

mifare ×1

nfc ×1

tags ×1