From 471f92a9677acdd235b0a3627dc2413b58973557 Mon Sep 17 00:00:00 2001 From: Raoul Date: Tue, 10 Mar 2015 22:06:17 -0400 Subject: [PATCH] Check if NFC is available on device --- .../org/sufficientlysecure/keychain/ui/ViewKeyActivity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index c94b29bac..637496c61 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -25,6 +25,7 @@ import android.annotation.TargetApi; import android.app.Activity; import android.app.ActivityOptions; import android.content.Intent; +import android.content.pm.PackageManager; import android.database.Cursor; import android.graphics.Bitmap; import android.net.Uri; @@ -373,6 +374,11 @@ public class ViewKeyActivity extends BaseActivity implements @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void invokeNfcBeam() { + //Check if device supports NFC + if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) { + Toast.makeText(this, R.string.no_nfc_support, Toast.LENGTH_SHORT).show(); + return; + } // Check for available NFC Adapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this); if (mNfcAdapter == null || !mNfcAdapter.isEnabled()) {