我不想在使用另一个开发应用程序时打开已经关闭的应用程序
I don't want to open my already closed app while I use my another develop app
我这里有我的代码,它会在标记任何 NFC 时在后台打开(或关闭)
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.nfc_rfid_rw.MainActivity"
android:label="@string/app_name"
android:launchMode="singleInstance"
>
<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"/>
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action
android:name="android.nfc.action.TAG_DISCOVERED">
</action>
<category
android:name="android.intent.category.DEFAULT">
</category>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
</activity>
</application>
我的问题是当我使用这个应用程序扫描任何 NFC 时它不会打开我的应用程序,我想做同样的事情,我不想打开这个应用程序,当我使用另一个应用程序时它会在后台打开(我开发的应用程序)。
我使用的这个应用无法打开我的应用(不是我的开发应用)
应用https://play.google.com/store/apps/details?id=com.wakdev.wdnfc&hl=zh_TW
在此项目中找到答案https://github.com/nadam/nfc-reader
在 onCreate
中,它有 PendingIntent
,如下所示:
pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
恢复时:
nfcAdapter.enableForegroundDispatch(this, pendingIntent, null, null);
在我的应用中定义这个之后,我开发的每个应用都不会跳转到我的第一个应用(或选择我想使用的应用),我只能使用前台应用!!
我这里有我的代码,它会在标记任何 NFC 时在后台打开(或关闭)
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.nfc_rfid_rw.MainActivity"
android:label="@string/app_name"
android:launchMode="singleInstance"
>
<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"/>
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action
android:name="android.nfc.action.TAG_DISCOVERED">
</action>
<category
android:name="android.intent.category.DEFAULT">
</category>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
</activity>
</application>
我的问题是当我使用这个应用程序扫描任何 NFC 时它不会打开我的应用程序,我想做同样的事情,我不想打开这个应用程序,当我使用另一个应用程序时它会在后台打开(我开发的应用程序)。
我使用的这个应用无法打开我的应用(不是我的开发应用)
应用https://play.google.com/store/apps/details?id=com.wakdev.wdnfc&hl=zh_TW
在此项目中找到答案https://github.com/nadam/nfc-reader
在onCreate
中,它有 PendingIntent
,如下所示:
pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
恢复时:
nfcAdapter.enableForegroundDispatch(this, pendingIntent, null, null);
在我的应用中定义这个之后,我开发的每个应用都不会跳转到我的第一个应用(或选择我想使用的应用),我只能使用前台应用!!