我想通过NFC将一个简单的字符串(text/plain)从一个Android设备发送到另一个.我能够以简单的字符串格式发送消息,并在恩智浦和其他提供商的一些已经制作的应用程序中读取.我在NDEFMessage中发送字符串.
public class MainActivity extends Activity
{
private NfcAdapter mAdapter;
private PendingIntent mPendingIntent;
private IntentFilter[] mFilters;
private String[][] mTechLists;
private TextView mText,txtRead;
private int mCount = 0;
Tag detectedTag;
ReadWrite rd;
@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
setContentView(R.layout.activity_main);
mText = (TextView) findViewById(R.id.text);
txtRead = (TextView) findViewById(R.id.txtRead);
mText.setText("Scan a tag");
rd=new ReadWrite();
mAdapter = NfcAdapter.getDefaultAdapter(this);
detectedTag =getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);
// Create a generic PendingIntent that will be deliver to this activity. The NFC stack
// will fill in the intent with the …Run Code Online (Sandbox Code Playgroud)