Hi,
I am new to android, and got one nexus s, so while trying to play with
NFC Capabilities, when i try to write to a mifare classic 1k card ,
Ndef.get(tag) returns null, upon searching, i find that tag is not
listed in tech list. but when i issue getTechList() command, i am able
to find
MifareClassic , NdefA and Ndefformatable are listed, so where am i
missing.

here is my code
public void onClick(View v) {


                        IntentFilter ndef=new
IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED );
                        try{
                                ndef.addDataType("*/*");
                        }catch(MalformedMimeTypeException e){
                                throw new RuntimeException("fail",e);
                        }

                        mFilters=new IntentFilter[]{ndef,};
                        showMessage( mFilters.toString());
                        // Setup a tech list for all NfcF tags
                        mTechLists = new String[][] { new String[] { 
MifareClassic.class
                                        .getName() } };

                        Intent intent=getIntent();
                        String action=intent.getAction();
                        if(NfcAdapter.ACTION_TECH_DISCOVERED.equals(action) ){
                        String msg="Discovered Tag with Intent " + intent;
                        status_Data.setText(msg);
                        Tag 
tagFromintent=intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
                        MifareClassic mfc=MifareClassic.get(tagFromintent);
                        boolean auth=false;
                        try {
                                String[] ttype=tagFromintent.getTechList();
//                              Ndef ndef1=Ndef.get(tagFromintent); [here i am 
getting null]


                                mfc.connect();
                                auth = mfc.authenticateSectorWithKeyA(0,
                                                MifareClassic.KEY_DEFAULT);
                        } catch (IOException e1) {
                                status_Data.setText("Authentication of Block 1 
Failed");
                        }
                try {
                        if (auth){
                        write(tagFromintent);}
                } catch (IOException e) {
                        status_Data.setText(e.toString());

                } catch (FormatException e) {
                        status_Data.setText(e.toString());
                        //e.printStackTrace();
                }


                        }else{
                                showMessage("Nothing to read");
                        }
                }
        };

any help will be greatly appriciated.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to