Harald Hoyer
Harald Hoyer

Reputation: 1303

Why does Android NFC not work with my Activity?

Once I modified an Android app and added NFC capabilities. But it just didn't work. The "Tap to Beam" just would not appear.

Long story short. The app had:

    getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);

Upvotes: 0

Views: 277

Answers (2)

Michael Roland
Michael Roland

Reputation: 40831

Android Beam will only work if the system is permitted to take a sceenshot of your activity. Hence, if you set the FLAG_SECURE (and consequently prevent screenshots while your activity is visible), you also prevent Android from taking the screenshot that would normally be displayed in the Beam UI. Consequently, no Beam UI will be shown and Beam will not work for your activity.

Upvotes: 1

Harald Hoyer
Harald Hoyer

Reputation: 1303

NFC does not seem to work, if LayoutParams.FLAG_SECURE is set.

    getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);

Upvotes: 2

Related Questions