繁体   English   中英

Android 库:是否可以将 Intent 传递到我的库中以检索 ParcelableExtra 的

[英]Android Library: Is it possible to pass an Intent into my Library to retrieve the ParcelableExtra's

我想使用 Intent 的 ParcelableExtra function 来检索 android.nfc.Tag Object

nfcTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

在 newIntent function 中,此代码有效。 但现在我想编写一个 Android 库,它使用相同的 android.nfc.Tag Object。

是否有可能和 state 将 Intent 传递到 Android 库中?

将 Intent object 传递给库并不是“最先进的”,虽然这在技术上可能是可行的,因为 Intent 只是标准类型 Java ZA2F2ED4F8EBC2CBB4C21A29DC40AB61 内的方法之间传递的一个实例在图书馆。

The reason why you should not uses the Intent Object is because the newer and better NFC API of enableReaderMode does not use Intent s it just gets passed the Tag Java Object directly when a Tag is discovered.
因此,您的图书馆最好接受Tag object 作为输入,因为它可以与较旧和较新(更好)的 NFC API 一起使用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM