0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Flutter][Android] 他のアプリを抑制しつつNFC タグを読み込む

Posted at

課題

NFCタグをアプリから読み込もうとしたが、他のアプリも反応してしまう。
アプリを開いているときは、他のアプリが反応しないようにしたい。

環境

対策

enableForegroundDispatch を使うことで抑制できる。
自分が前面にあることが条件。

答えは、プラグイン作者のサンプルにありました。
https://github.com/okadan/nfc-manager/blob/master/android/app/src/main/kotlin/com/naokiokada/nfcmanager/MainActivity.kt

ただし古いので、最新の Android SDKに対応するには PendingIntent生成時に PendingIntent.FLAG_IMMUTABLE を指定しないと起動しません。

後記

NFCタグは工夫次第で色々と使えそうに感じました。
ただ利用するには、タグに書き込む内容に対する Android/iOS それぞれの振る舞いはどうか、複数のタグを書き込んだ場合の振る舞いはどうか、など色々と勉強が必要ですね!

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?