ANdroid with MiFare SDK issue…

Forum / MIFARE SDK / ANdroid with MiFare SDK issue…

  • 6. May 2015 at 19:27
    Inxpnfclibcallback
    is the problem... I put everything up on pastebin...

    http://pastebin.com/97yzzP6e

    libInstance.filterIntent(intent, new Inxpnfclibcallback() {
    is causing some troubles... the pastebin details what my probelms are.

    wrong 2nd argument type.

    I have been experimenting with the imports but no luck so far.
    thanks


    update:
    I was following the tutorial PBX.
    the Docs say to do...
    libInstance.filterIntent(intent, new Inxpnfclibcallback() {
    but I replaced it with
    libInstance.filterIntent(intent, new nxpnfclibcallback() {
    and redid the imports. but the event is still not firing when I try to read a mifare classic.
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    6. May 2015 at 22:09
    You have not initialized and used they KeyStore. Also, you haven't used your LICENSE KEY to register the activity. If you are using Advanced MIFARE SDK (which I assume you do, because you use Inxpnfclibcallback).

    If you do not use the Advanced MIFARE SDK, you are following wrong tutorials, as you need to follow a tutorial for LITE Version - or check my post below this one.

    If you have your LICENSE KEY follow the below suggestions:


    Add this before onCreate inside MainActivity

    private IKeyStore ks = null;
    public static final byte[] KEY_DEFAULT_FF = { (byte) 0xFF, (byte) 0xFF,
    (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };


    in your onCreate (inside MainActivity) write this:

    libInstance = NxpNfcLib.getInstance();
    // Get the Keys for Licensing and Cards
    getKey();

    create the method getKey(), here's my example:

    private void getKey() {

    try {
    ks = KeyStoreFactory.getInstance().getSoftwareKeyStore();
    ks.formatKeyEntry(0, IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_MIFARE);
    ks.setKey(0, (byte)0, IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_MIFARE, KEY_DEFAULT_FF);
    } catch (SmartCardException e) {
    e.printStackTrace();
    }
    libInstance.loadKeyStore(ks);
    libInstance.registerActivity(this, LICENSE_KEY);
    }


    And then use youre onNewIntent as you use it inside your example. It should work now.

    If you haven't registered your App yet, you can do it here: https://inspire.nxp.com/mifare/

    Hope it helps,
    David
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    6. May 2015 at 22:17
    However, if you are indeed using LITE version, try change:

    "new Inxpnfclibcallback" to "new Inxpnfcliblitecallback" inside your onNewIntent() method.

    Please let me know if it helped.

    David
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 0:21
    I was using the Lite version.

    2... The PDF that I was following came out of the MiFare Lite SDK package.
    Its titled... UM10853_UserManual_Getting_Started_with_MifareSDK_Lite.pdf

    3... Does the LITE version require a LICENSE KEY to register the activity.?

    4... I can get the app to load on my Android Samsung Galexy 3. But when I scan a mifare tag, it launches another program. It is not hitting the onNewIntent(Intent intent) at all...

    5... And I am not sure the app is sending back a registration?
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 8:08
    If you use the LITE version, you DONT need the LICENSE KEY.

    Have you tried replacing the things I wrote one post above yours in your code?

    Best Regards,
    David
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 9:47
    Hi, I faced the same problems too, need suggestion and help...

    protected void onNewIntent(Intent intent) {
    libInstance.filterIntent(intent, new Inxpnfcliblitecallback() {
    ///// error : Inxpnfcliblitecallback cannot be resolved to a type
    ///// error : the method filterIntent(Intent, lnxpnfcliblitecallback) in the type is not applicable for the arguments (Intent, new lnxpnfcliblitecallback(){})
    @Override
    public void onUltraLigthCardDetected(MifareUL objUlCard) {
    ///// error : MifareUL cannot be resolved to a type
    Log.i(TAG,"UltraLight Card Detected" );
    objUlCard.connect();
    }
    });

    super.onNewIntent(intent);
    }
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 10:05
    Hey Duniadamay,

    This error occurs only when you forgot to Import the neccessary classes to work with your code. So perhaps check that, if you have imported Inxpnfcliblitecallback, and MIfare Ultralight class.

    Best,
    David
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 10:24
    Hi David, thanks for the fast respon...

    libInstance.filterIntent(intent, new Inxpnfclibcallback() {
    /// error : I've already import 'Inxpnfclibcallback' (com.nxp.nfclib.interface)

    Log.i(TAG,"UltraLight Card Detected" );
    /// error : TAG cannot be resolved : I've add the code 'private String TAG;'

    import com.nxp.nfclib.Interface.Inxpnfclibcallback;
    import com.nxp.nfcliblite.Interface.NxpNfcLibLite;

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.Menu;
    import android.view.MenuItem;

    public class MainActivity extends Activity {
    .....
    ......
    protected void onNewIntent(Intent intent) {
    libInstance.filterIntent(intent, new Inxpnfclibcallback() {

    private String TAG;

    @Override
    public void onUltraLigthCardDetected(MifareUL objUlCard) {
    Log.i(TAG,"UltraLight Card Detected" );
    objUlCard.connect();
    }

    @Override
    public void onUltraLigthEV1CardDetected(MifareUL objUlCardEV1) {
    Log.i(TAG,"UltraLight Card EV1 Detected" );
    objUlCardEV1.connect();
    }
    });

    super.onNewIntent(intent);
    }
    }



    ----------------------------------------------------------------------------------------
    I rename the lnxpnfclibcallback -> lnxpnfcliblitecallback

    import com.nxp.nfcliblite.Interface.Inxpnfcliblitecallback;
    import com.nxp.nfcliblite.Interface.NxpNfcLibLite;

    protected void onNewIntent(Intent intent) {
    libInstance.filterIntent(intent, new Inxpnfcliblitecallback() {

    private String TAG;

    @Override
    public void onUltraLigthCardDetected(MifareUL objUlCard) {
    Log.i(TAG,"UltraLight Card Detected" );
    objUlCard.connect();
    }

    @Override
    public void onUltraLigthEV1CardDetected(MifareUL objUlCardEV1) {
    Log.i(TAG,"UltraLight Card EV1 Detected" );
    objUlCardEV1.connect();
    }
    });
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 10:49
    Can you put your entire code on some sort of Paste-bin or something like that, that I can check it entirely?

    Tell me what SDK you use, LITE or Advanced ?

    BR,
    David
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 10:56
    Dear David,

    I used this document :UM10853_UserManual_Getting_Started_with_MifareSDK_Lite.pdf

    http://pastebin.com/3b8UaEP5

    best regards,
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 11:05
    Could you try to change this:

    "libInstance.registerActivity(this);"

    with

    "libInstance.registerActivity(MainActivity.this, false);"

    Let me know if it changed something?

    Best Regards,
    David
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 11:21
    libInstance.registerActivity(MainActivity.this, false);
    //// error : remove argument to match 'registerActivity(Activity)'

    libInstance.registerActivity(MainActivity.this); //// not error anymore, it's okay?

    libInstance.filterIntent(intent, new Inxpnfcliblitecallback() {
    //// add unimplemented method

    http://pastebin.com/gsN33tg8
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 11:24
    Without "false" it is ok. I was brainstorming something.
    Now it really look good (the code).

    So now it works ?

    // Yes, add the unimplemented methods

    Check Logs while you Tap your card to see if it gets recognized inside the Logcat (if you use android studio for example).
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 11:37
    :-D I don't have any smartphone with nfc things yet, just the ACR122U...
    The code free of error, I can clean and build the program...
    I am running the program form emulator, and right now I still don't know what to do >:-) ...
    Is this code only for smartphone with NFC?
    Or you can show me some way to get a tutorial for detect some card reader...
    Thanks a lot....
    + 0  |  - 0

    Re: ANdroid with MiFare SDK issue…

    7. May 2015 at 12:43
    Well this SDK is to develop with Android. This means you need a smartphone to test it.
    In your case, an emulator cannot work currently, as the ACRU reader (as far as I'm aware of currently) works with windows and cannot interact with Android Studio's emulator.

    Best would be to get a Smartphone with NFC chip and test your Application with it. You'll know for sure. But if the code compiled, it should be working.
    Nice job! :)

    David
    + 0  |  - 0
Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.