小编Sag*_*and的帖子

如何通过nfc将简单的字符串从android发送到android?

我想通过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)

android nfc

6
推荐指数
0
解决办法
4442
查看次数

标签 统计

android ×1

nfc ×1