[英]how to launch specific activity when nfc detect tag?
Currently I am working with nfc reader.目前我正在使用 nfc 阅读器。 In this application nfc read tags and redirect to specific activity.在此应用程序中,nfc 读取标签并重定向到特定活动。 But I want to redirect when user in background or app in kill state.但是我想在用户处于后台或应用程序处于终止状态时重定向。
my manifest file我的清单文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.adsmn.nfsreader">
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<uses-permission android:name="android.permission.NFC" />
<application
android:hardwareAccelerated="false"
android:largeHeap="true"
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:roundIcon="@drawable/app_icon"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Activity.Event_Executed"
android:screenOrientation="landscape"></activity>
<activity android:name=".Activity.VideoViewActivity"
android:screenOrientation="landscape"/>
<activity
android:launchMode="singleTask"
android:name=".Activity.Tech_Activation_Activity"
android:screenOrientation="landscape" />
<activity android:name=".Activity.MainActivity"
android:launchMode="singleTask"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<action android:name="android.nfc.action.ACTION_TAG_DISCOVERED" />
<data android:mimeType="text/plain" />
</intent-filter>
<!-- no need to use this when user to open deafualt app-->
<!-- <meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />-->
</activity>
<activity android:name=".Activity.ViewPaigerClass"
android:launchMode="singleTask"
android:screenOrientation="landscape"></activity>
</application>
I have all ready tried some answer from stack overflow but none of them worked, So please tell me some thing that what I am doing wrong.我已经准备好从堆栈溢出中尝试一些答案,但没有一个起作用,所以请告诉我一些我做错了什么。 Thanks in advance提前致谢
You need to use deeplink for launching a specific Activity or Fragment.您需要使用深层链接来启动特定的 Activity 或 Fragment。
And make your activity android:launchMode="singleTop"
并使您的活动android:launchMode="singleTop"
Here is the reference for how to make deeplink.这是如何制作深层链接 的参考。
For the fragment, you'd better to check Navigation Component .对于片段,您最好检查Navigation Component 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.