Answer the question
In order to leave comments, you need to log in
How to process an NFC tag in a running Activity?
Good day.
I am writing a program to read / write data to the controller via NFC. There was an unexpected problem in usability: if several programs for working with NFC are installed on the smartphone, the OS each time prompts me to choose which one to use, even if my program is already running. If you choose mine, it correctly works either onCreate or onNewIntent (depending on whether it was launched or not).
How can an android explain that if the application is already running, it is not necessary to re-offer a choice of programs for working with the label?
I write in Java in Android Studio under Android 6.
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="aaa.nfctest">
<uses-sdk android:minSdkVersion="10"/>
<uses-permission android:name="android.permission.NFC"/>
<uses-feature
android:name="android.hardware.nfc"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:launchMode="standard">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".nfc" android:launchMode="singleTask">
<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>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
</application>
</manifest>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question