I have an application NFC capable. If I don't start it from NFC tag it resumes normaly even from notification bar, even by long pressing home button. The problem is when I start the application with the NFC tag. When I try to resume, it restarts the application. Any suggestions?
This is my launcher activity in the manifest file
<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>
This is where I create my notification.
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());
}