Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid activity intent launching
    primarykey
    data
    text
    <p>I'm stuck for a couple of hours on a stupid problem.</p> <p>My application is composed by 2 activities: A (master) and B. There is also one service S. The "normal" tasks stack is AB and S is running in background. </p> <p>My issue is appeared when I would like directly reach the activity B with a notification. I have to construct the tasks stack to obtain AB in order to keep the default behaviour of the return button. (I want the user could back to A).</p> <p>Because I have use the API 7, I can't use an intent array as show in the android developpers tutorial <a href="http://developer.android.com/guide/topics/ui/notifiers/notifications.html" rel="nofollow">http://developer.android.com/guide/topics/ui/notifiers/notifications.html</a>. So I have decided to add a custom action (S.ACTION_CUSTOM) in the intent sent by the notification in order to distinguish this case in the onCreate() of the activity A.</p> <p>Intent associated to the notification declared in the service S :</p> <pre><code>Intent notificationIntent = new Intent(this, A.class); notificationIntent.setAction(ACTION_CUSTOM); </code></pre> <p>Now in A, at the end of the onCreate() method, I add:</p> <pre><code>if (S.ACTION_CUSTOM.equals(getIntent().getAction())) { Intent intent = new Intent(this, B.class); intent.setAction(S.ACTION_CUSTOM); startActivity(intent); } </code></pre> <p>This code works to go directly to B from notification and it authorize the return to A. But once I have use the notification "shorcut", then B is directly reached when the application start, even from the home menu. I have tried many things to understand what happen but even if I add getIntent().setAction(ANYTHING) at the end of the if statement in A, the behaviour is the same. </p> <p>Could anyone tell me what happening with my code please ? Morover I'm open minded with an other method to get my wishes.</p> <p>Thanks.</p> <p>Edit:</p> <p>Part of the XML manifest:</p> <pre><code>&lt;activity android:name=".A" android:label="@string/app_name" &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=".B" android:label="@string/app_name" &gt; &lt;/activity&gt; </code></pre> <p>But I think intent filters have nothing to do with my problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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