NFC 対応のアプリケーションがあります。NFCタグから起動しないと、ホームボタンを長押ししても、通知バーからでも正常に再開します。問題は、NFC タグを使用してアプリケーションを起動するときです。再開しようとすると、アプリケーションが再起動します。助言がありますか?
これは、マニフェスト ファイル内の私のランチャー アクティビティです
<activity
android:name=".hmi.DebugPreferenceActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme"
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.TECH_DISCOVERED" />
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/filter_nfc" />
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
ここで通知を作成します。
private void createNotification() {
Intent notificationIntent = new Intent(mContext, DebugPreferenceActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0,
notificationIntent, 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this)
.setSmallIcon(R.drawable.app_icon)
.setContentTitle(
mContext.getResources().getString(R.string.app_name))
.setContentIntent(pendingIntent).setContentText(null);
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder.setOngoing(true);
mNotificationManager.notify(0, mBuilder.build());
}