What does registerActivity do?

Forum / MIFARE SDK / What does registerActivity do?

  • 21. December 2016 at 17:19
    I had previously asked a question in the wrong forum here: https://www.mifare.net/support/forum/topic/what-does-registeractivity-do/#post-19497

    I would like to continue the discussion in this forum (which I assume is the correct one).

    Here is the link for the project sample mentioned in the last post:

    https://expirebox.com/files/3a6442430fb31e3a9f7250974eb5a554.zip
    + 0  |  - 0

    Re: What does registerActivity do?

    27. December 2016 at 12:15
    Hi Francisco,

    Yea, this is the better column for your question. Anyway, your questions seems unclear for me. We have tested TapLinx on various phones—without any problems.

    As you can see in the example app and in the skeletons, enclosed with the AN, the library is initialized in onCreate() (like all other libraries would do it) and the library is located in the main activity, because only the main activity will receive NFC intents from Android. Of course, you can have more activities in your app, but only the main activity should be able to receive NFC intents. If you need processing of NFC data in other activities of your app, you should do it via separate threads or use other mechanisms of inter-app-communication.

    I do not see any “design flaws” to locate the library instance in the main activity, when only the main activity will receive NFC intents from Android. The attempt to try to get NFC intents to multiple activities of the same app makes no sense for me, because this opens synchronization troubles and as I know, it is not supported by Android.

    I will do my best to support you, but I do not have time to download customer code and start investigations on this code. Sorry.

    Kind regards,
    The TapLinx Team

    + 0  |  - 0

    Re: What does registerActivity do?

    27. December 2016 at 14:17
    As you can see in the example app and in the skeletons, enclosed with the AN, the library is initialized in onCreate() (like all other libraries would do it) and the library is located in the main activity, because only the main activity will receive NFC intents from Android. Of course, you can have more activities in your app, but only the main activity should be able to receive NFC intents


    And that's a design flaw. You are forcing the users of the SDK to have only one activity capable of receiving NFC intents and then forcing to use some complicated methods to retrieve the data.

    If you need processing of NFC data in other activities of your app, you should do it via separate threads or use other mechanisms of inter-app-communication.
    This also doesn't make to me sense because: (1). using different threads has nothing with the problem at hand since once an activity is paused you can't access its intents. (2). Inter-app-communication in this scenario tells me that the SDK wasn't thought to be used in more than one activity (and Android doesn't restrict you to only use NFC in one activity).

    The attempt to try to get NFC intents to multiple activities of the same app makes no sense for me, because this opens synchronization troubles
    I don't understand what you mean by this. Imagine this use case: The user will be presented with an UI screen in activity A, and in this activity A will be able to receive NFC intents. Then the user navigates to activity B, with a different UI, and will also receive NFC intents. Nowhere did I state that I wanted to receive intents simultaneously in various activities.

    but I do not have time to download customer code and start investigations on this code.
    Don't worry, it isn't customer code, it is the example app enclosed in the AN which only has one activity more (a very simple one in fact). But now I see it is unnecessary for you to download it since you already solved my issue which was: The library doesn't support more than one activity.
    + 0  |  - 0

    Re: What does registerActivity do?

    28. December 2016 at 12:19
    Francisco,

    The TapLinx SDK sit on top of the NFC Android library. Your app has to declare to receive NFC intents and implement a callback method onNewIntent() which is used by Android to feed your app with any kind of intents. This is the Android architecture. You can love it or hate it, but you have to live with this architecture if you want to build Android apps.

    TapLinx is a library layer inside of your app to process NFC data. All our examples shows to feed TapLinx directly in onNewIntent() and use the data stream in your application code. If you need the NFC data stream in several activities, I would use the Android inter-app-communication mechanisms to handover to the different endpoints. If this is not acceptable for you, you can try to implement several onNewIntent() methods in your app and use also several instances of TapLinx to handle the NFC data. But I am in doubt this is a good idea.

    Anyway, all this has nothing to do with serious customer questions about TapLinx using pattern. I regard the matter as closed.
    The TapLinx Team

    + 0  |  - 0
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.