Monday, 16 May 2016

Android NFC AndroidManifest.xml




AndroidManifest.xml


   <application  
     android:name="com.marksandspencer.MSApplication"  
     android:allowBackup="true"  
     android:icon="@mipmap/ic_launcher"  
     android:label="@string/app_name"  
     android:supportsRtl="true"  
     android:theme="@style/AppTheme" >  
     <activity android:name=".views.MainActivity"  
       android:label="@string/app_name"  
       android:launchMode="singleTop"  
       android:screenOrientation="portrait" >  
       <intent-filter>  
         <action android:name="android.intent.action.MAIN" />  
         <category android:name="android.intent.category.LAUNCHER" />  
       </intent-filter>  
       <intent-filter>  
         <action android:name="android.nfc.action.NDEF_DISCOVERED"/>  
         <category android:name="android.intent.category.DEFAULT"/>  
         <data android:scheme="http"  
           android:host="@string/api_hostname"  
           />  
         <data android:scheme="https"  
           android:host="@string/api_hostname"  
           />  
       </intent-filter>  
     </activity>  


android:host="@string/api_hostname", This is just filters of your app. if  you are not using your app, for example you are on the main page (phone home page), and if user scanned a NFC (with url=a.com/afdafsdfasf), and your android:host="a.com" then the system will popup your app as an option of dealing with the tag. if you scan another NFC (with url=b.com/adfasf), the system will not popup your app as an option.

About settings only work for the main page popup windows.

You still need to handle the NFC and process the data in it.





http://code.tutsplus.com/tutorials/reading-nfc-tags-with-android--mobile-17278

http://developer.android.com/guide/topics/connectivity/nfc/nfc.html


http://developer.android.com/guide/topics/connectivity/nfc/advanced-nfc.html#foreground-dispatch






No comments:

Post a comment