1. Download our Official Android App: Forums for Android!

Apps Making NFC app as default when scanning tag

Discussion in 'Android Development' started by skumarm226, May 3, 2012.

  1. skumarm226

    skumarm226 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    May 3, 2012

    May 3, 2012
    6
    0
    5
    Hi,

    I have coded an NFC application, but everytime i scan the tag i need to go to my application.
    Currently when i scan tag, a pop up menu shows other nfc applications like one from nxp...

    Is there a way ,when i scan tag my application can appear or start as default app.

    thanks
    kumar
     

    Advertisement

  2. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    This is entirely up to the user. when the user is presented with the list of installed apps that support the action to choose from, there should be a checkbox at the bottom of the dialog that says something like "Use as default"
     
    alostpacket likes this.
  3. skumarm226

    skumarm226 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    May 3, 2012

    May 3, 2012
    6
    0
    5
    Unfortunately my app doesn't show up in list of installed app when i scan the tag. Some of the other NFC app i downloaded show..Is there any code or permission i need to set in the manifest.
     
  4. wubbzy

    wubbzy Well-Known Member
    Rank:
    None
    Points:
    63
    Posts:
    109
    Joined:
    Dec 19, 2011

    Dec 19, 2011
    109
    32
    63
    *nix kernel's by day
    Silicon Valley
    You need to tell the Droid that your app must be presented in the picker on certain user action like Nfc or when someone takes photo. For Nfc this would be ACTION_NDEF_DISCOVERED add to manifest file as category default. Intents from manifest are registered system wide so when that intent happens android will present picker with relevant registrations

    e.g.
    <intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="text/plain" />
    </intent-filter>

    will register your app to receive to receive nfc data

    pay attention to mimeType, you can adjust it as you need it, for further reference:

    NFC Basics | Android Developers
     
    alostpacket likes this.

Share This Page

Loading...