简体   繁体   中英

Android-Confusion with NFC Manifest Tags in AndroidManifest.xml

I want to open my MainActivity automatically as soon as I show the tag near by my Android Tablet. My Manifest file is shown below.

      <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.nfc"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="16" />

    <application

        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
    android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.nfc.MainActivity"
            android:label="@string/app_name" >

<intent-filter>
  <action android:name="android.nfc.action.NDEF_DISCOVERED"/> 
  <category android:name="android.intent.category.DEFAULT"/>
   <data android:mimeType="application/com.example.nfc"/> 
  </intent-filter>       
</activity>
  <activity android:name=".NewConnection">


 </activity>
        </application>

</manifest>

But My MainActivity does not be opened when I show the tag .

And I need Another help that I have a button in MainActivity when I click that button NewConnection Activity must be opened.In NewConnection Activity I need to write some content in Edittext.After I entered the contents if I show the tag the content must be written in the tag .

for that ,what I need to give insted of question marks i given

  <activity android:name=".MainActivity">
    .
    .
    .
    <intent-filter>

     ????????
     ???????

    </intent-filter>

</activity>




  <activity android:name=".NewConnection">
    .
    .
    .
    <intent-filter>

     ????????
     ???????

    </intent-filter>

</activity>

please help me friends .

Take a look here, this post explains how an Intent can be dispatched to your activity upon the system recognizing a new tag.

How to discover any NFC tech (not only tags) using Android?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM