starting an Activity from Broadcast Receiver brings up Default Activity
<p>My app contains two activity, one widget and a broadcast receiver.</p>

<p>First activity is default one which is called by home launcher. Second activity is a reminder dialog activity which plays a MP3 and has a dismiss button. It will appear on home screen.</p>

<p>My widget is a custom clock which setup an alarm to call a broadcast receiver every minutes which is responsible to update the clock. There are some reminders at specific time which broadcast receiver calls the reminder activity.</p>

<p>My app now is fully working, but there is a small problem: When app is open in the background (It's not on screen), when broadcast receiver start the reminder activity, the default activity comes first and reminder activity is shown over that. But when I close the app, reminder activity appears on home screen and there is no problem.</p>

<p>This is the code I use to startActivity from receiver:</p>

<pre><code>context.startActivity(new Intent(context, ActivityReminder.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP));
</code></pre>

<p>And this is android manifest:</p>

<p></p>

<pre><code>    &lt;activity android:name=".MyActivity"
        android:theme="@android:style/Theme.Black.NoTitleBar"
        android:label="@string/app_name"
        android:screenOrientation="portrait" &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=".ActivityReminder" android:label="@string/reminder" android:screenOrientation="portrait" android:theme="@style/Theme.CustomDialog"  /&gt;

    &lt;receiver android:name=".widget"
        android:label="@string/app_name"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt;
        &lt;/intent-filter&gt;
        &lt;meta-data android:name="android.appwidget.provider"
            android:resource="@xml/widget" /&gt;
    &lt;/receiver&gt;

    &lt;receiver android:name=".UpdaterReceiver" /&gt;
</code></pre>

<p>For now I use this workaround in the default activity to solve the problem, it work just like closing the app:</p>

<pre><code>@Override
protected void onPause()
{
    super.onPause();
    finish();
}
</code></pre>

<p>I found something more annoying. If the main activity is not closed, every call from broadcast receiver opens the activity again even it's open already. Although if the main activity is closed, subsequent call won't do anything.</p>
