Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: startActivity from a receiver also starts the MAIN activity (action.MAIN / category.LAUNCHER)
    text
    copied!<p>When i'm using startActivity from a receiver like this:</p> <pre><code>public void onReceive(final Context context, final Intent intent) { Intent i = new Intent(); i.setClass(context, NewClass.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); i.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); context.startActivity(i); } </code></pre> <p>in some devices (Galaxy S2 android: 4.0.4 for example) - it also starts in the backgrouns the MAIN activity (with action.MAIN and category.LAUNCHER).</p> <p>--<em>Edit</em>--</p> <p>AndroidManifest :</p> <pre><code>&lt;application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:debuggable="true"&gt; &lt;receiver android:name="com.my.app.MyBroadcastReceiver" android:enabled="true"&gt; &lt;intent-filter android:priority="99999"&gt; &lt;action android:name="android.intent.action.PHONE_STATE" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;activity android:name="com.my.app.Main"&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="com.my.app.NewClass"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.NEWSCLASS" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; </code></pre> <p>Why is that?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload