80,493
社区成员
发帖
与我相关
我的任务
分享
package my.nfc.namespace;
import android.app.Activity;
import android.content.Context;
import android.nfc.NfcAdapter;
import android.nfc.NfcManager;
import android.os.Bundle;
import android.widget.*;
public class NFCActivity extends Activity {
/** Called when the activity is first created. */
TextView textview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textview = (TextView) findViewById(R.id.textview);
NfcManager manager = (NfcManager) getSystemService(Context.NFC_SERVICE);
NfcAdapter adapter = manager.getDefaultAdapter();
if(adapter.isEnabled()){
String s1 = "open";
textview.setText(s1);
}
}
}