mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
test also whether NFC turned on
This commit is contained in:
parent
b3bc738cae
commit
b7d756957c
2 changed files with 12 additions and 3 deletions
|
@ -411,7 +411,7 @@ public class DlgDelegate {
|
|||
.setPositiveButton( R.string.button_text, lstnr )
|
||||
.setNegativeButton( R.string.button_html, lstnr );
|
||||
|
||||
if ( NFCUtils.nfcAvail() ) {
|
||||
if ( NFCUtils.nfcAvail( m_activity ) ) {
|
||||
builder.setNeutralButton( R.string.button_nfc, lstnr );
|
||||
}
|
||||
Dialog dialog = builder.create();
|
||||
|
|
|
@ -21,10 +21,12 @@
|
|||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.nfc.NdefMessage;
|
||||
import android.nfc.NdefRecord;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.nfc.NfcManager;
|
||||
import android.os.Parcelable;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
|
@ -32,9 +34,16 @@ public class NFCUtils {
|
|||
private static boolean s_inSDK =
|
||||
14 <= Integer.valueOf( android.os.Build.VERSION.SDK );
|
||||
|
||||
public static boolean nfcAvail()
|
||||
public static boolean nfcAvail( Context context )
|
||||
{
|
||||
return s_inSDK /*&& turnedOn*/;
|
||||
boolean result = s_inSDK;
|
||||
if ( result ) {
|
||||
NfcManager manager =
|
||||
(NfcManager)context.getSystemService( Context.NFC_SERVICE );
|
||||
NfcAdapter adapter = manager.getDefaultAdapter();
|
||||
result = null != adapter && adapter.isEnabled();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void buildAndPush( Activity activity, String data )
|
||||
|
|
Loading…
Reference in a new issue