使用NFC标签启动地图但没有获得标记

时间:2015-05-02 07:58:58

标签: android google-maps nfc ndef

我通过传递坐标使用NFC标签启动Google地图,但没有得到标记......

如果我想在该位置显示标记怎么办?

writeMapButton.setOnClickListener(new android.view.View.OnClickListener() 
 {
    public void onClick(View view) {

       urlAddress = "geo:"+latitude+","+longitude;      

    }
});

mNfcAdapter = NfcAdapter.getDefaultAdapter(this); 
         mPendingIntent = PendingIntent.getActivity(this, 0,
                new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
        IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
        mFilters = new IntentFilter[] {
             ndef,
        };
          mTechLists = new String[][] { new String[] { Ndef.class.getName() },
               new String[] { NdefFormatable.class.getName() }};

@Override
    public void onNewIntent(Intent intent) {
        Log.i("Foreground dispatch", "Discovered tag with intent: " + intent);
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);  

        byte[] uriField = urlAddress.getBytes(Charset.forName("US-ASCII"));
        byte[] payload = new byte[uriField.length + 1];          //add 1 for the URI Prefix
        System.arraycopy(uriField, 0, payload, 1, uriField.length);  //appends URI to payload
        NdefRecord URIRecord  = new NdefRecord(
            NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], payload);
        NdefMessage newMessage= new NdefMessage(new NdefRecord[] { URIRecord });
        writeNdefMessageToTag(newMessage, tag);        
    }

0 个答案:

没有答案
相关问题