title: Unable to remove activity from stack,
body: <p>I am starting an activity from service. , </p>
  
  <p>In this i set <strong>two flags</strong> one is </p>
  
  <p><code>Intent.FLAG_ACTIVITY_NEW_TASK</code> 
  because i am  running activity from service.its new </p>
  
  <p><code>Intent.FLAG_ACTIVITY_NO_HISTORY</code> is set to new activity is not kept in the history stack.  As soon as the user navigates away from it, the activity is finished. </p>
  
  <p><strong>Here is the code which i call from service to open activity</strong> </p>
  
  <pre><code> public static void open(Context context){
  
          Intent intent=new Intent(context,PopupActivity.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_NO_HISTORY);
          context.startActivity(intent);    
      }
  </code></pre>
  
  <p>and i have cross button in my activity to destroy activity  , when i press cross button activity should remove from stack,but it remain in stack and when press home button to view it, activity recreated  in stack.for example "oncreate"  is again called </p>
  
  <p>here is my code.</p>
  
  <pre><code> @OnClick(R.id.flClose) void closeWindow(){
  
         finish();
      }
  </code></pre>
  
  <p>Here is my manifest activity code.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mypackagename"&gt;
  
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
      &lt;uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  
      &lt;application
          android:name=".app.MyApplication"
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme.NoActionBar"&gt;
          &lt;activity android:name=".SplashActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:name=".DashboardActivity"
              android:screenOrientation="portrait" /&gt;
          &lt;activity
              android:name=".SearchUserActivity"
              android:screenOrientation="portrait" /&gt;
          &lt;activity
              android:name=".TermsPolicyActivity"
              android:screenOrientation="portrait" /&gt;
          &lt;activity
              android:name=".UserDetailActivity"
              android:screenOrientation="portrait" /&gt;
          &lt;activity
              android:name=".DocumentViewerActivity"
              android:screenOrientation="portrait" /&gt;
  
  
  
          &lt;activity
              android:noHistory="true"
              android:name=".PopupEndActivity"
              android:configChanges="orientation|keyboardHidden"
              android:theme="@style/Theme.AppCompat.Transparent.NoActionBar" /&gt;
  
  
          &lt;activity
              android:name=".BlockActivity"
              android:theme="@style/Theme.AppCompat.Transparent.NoActionBar" /&gt;
  
  
          &lt;activity
              android:name=".BlockSettingsActivity"
              android:theme="@style/AppTheme.NoActionBar"
              android:configChanges="orientation|keyboardHidden"
              /&gt;
  
  
          &lt;service
              android:name=".service.SyncDataService"
              android:enabled="true"
              android:exported="false" /&gt;
  
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>