0

I am working on NFC application. when i application already opened and i read the information from NFC tag then activity open which registered Intent-Filter and this opens a new instance of application which has already opened.How can i close previous instance or open previous instance of application.

<activity android:name="com.tanzanite.realike.Fragments.MainActivity" android:screenOrientation="portrait"
         android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 
         android:noHistory="false">

        <intent-filter>
             <action   android:name="android.nfc.action.TECH_DISCOVERED" />
             <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>     
                       <meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/nfc_tech_filter" />
    </activity>

Please help me and Sorry for bad english.. Thanks in Advance.

Shivam saxena
  • 151
  • 1
  • 3
  • 8
  • 1
    You should use activity launch modes http://developer.android.com/guide/topics/manifest/activity-element.html#lmode – Georgy Gobozov Nov 28 '13 at 13:49
  • but its not working.activity not clear to previous activity..i used already this.. – Shivam saxena Nov 28 '13 at 13:52
  • @Shivamsaxena : if you already tried a suggestion from a comment/answer, but did not bother to mention it in the question, you're the only one to blame. plus, launchMode is exactly what you should be using. – njzk2 Nov 28 '13 at 13:56

2 Answers2

0

When you want to receive NFC tag discovery events while your activity is already in the foreground, you should register with the NFC foreground dispatch system. See Advanced NFC: Using the NFC Foreground Dispatch System. (See also this question.)

Community
  • 1
  • 1
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
-1

Step: 1

Create a Class (for example BusinessModel), this class extends Application. This class load once when the application launch. Step 2 In Android manifest.xml

 <application
    android:name="package name.BusinessModel"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name="package name.StartActivity"
        android:label="@string/app_name"
        android:screenOrientation="sensorLandscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Gnanaprakasam
  • 171
  • 1
  • 1
  • 8