Activity lifecycle - startActivity() with extras?

That's not what flag_activity_new_task means. Those flags only make sense for activities started within your process. Started an activity of another application will always start it as a new task, in a new process, with a new stack Apparently I'm wrong Activities defined in different applications can share an affinity I didn't know that.

I'm still not clear on exactly what you'd like to happen though And what do you mean "calling this the second time". The second time of what? And it resumes what?

What are you expecting?

That's not what flag_activity_new_task means. Those flags only make sense for activities started within your process. Started an activity of another application will always start it as a new task, in a new process, with a new stack.

Apparently I'm wrong. Activities defined in different applications can share an affinity. I didn't know that.

I'm still not clear on exactly what you'd like to happen though. And what do you mean "calling this the second time". The second time of what?

And it resumes what? What are you expecting?

If I remove the setFlags and I click the button to start the new 'other' app its loads displaying what I want. The user goes back to the home, and clicks on the 1st app to open it again, instead of the 1st app, the 'other' app is shown - with the flag this doesn't seem to happen. As for calling the second time: the user clicks the button, the other app loads showing the result of the passed extra.

If the user returns to the 1st app and presses the button again, the original version of the other app is resumed, using the original extra not the new from from the new button press. – Scoobler Oct 21 '10 at 21:13 Get the intent in onResume instead of onCreate. – blindstuff Oct 21 '10 at 21:22 By app do you mean activity?

Activities and Applications are not the same thing. – Falmarri Oct 21 '10 at 21:34 Sorry I mean application - I have two seperate applications, the user installs one (A) which is fully functional, then installs another one (B) which is fully functional. If the user has A and B installed a button appears in B, when the user clicks it, B opens A with an extra.

They are seperate packages. A=com.me. Myapp, B=com.me.otherapp.

I appreaciate the help I still haven't got my head fully round the whole lifecyle (java is only a hoby). – Scoobler Oct 21 '10 at 22:23.

The final answer to my question has been using the following: I created a function to handle loading intent extras: private void handleIntent(Intent intent) { Bundle extras = intent.getExtras(); if (extras! = null) { place = extras. GetString("place"); } } In onCreate I use: handleIntent(getIntent()); Then added the following function to get the intent when an existing instance of an activity is passed a new intent: public void onNewIntent(Intent intent) { setIntent(intent); handleIntent(intent); } I also added android:launchMode="singleInstance" to the activity declaration in the manifest of the activity with the above code.

Finally from the first package, I can now use the following code to start the second package with an extra. When the second package starts, the user can click on the first package (from the home launcher) and get the app they expect, and if they click to start the second package, the 'already running' instance is shown, but captures the new extra which has been passed: Intent I = new Intent("com.me.myapp. MY_MAP"); i.

PutExtra("place", place); startActivity(i); Hopefully this will be helpfull to someone - its probably not the best way to do this, but it works for me.

That's not what flag_activity_new_task means. Those flags only make sense for activities started within your process. Started an activity of another application will always start it as a new task, in a new process, with a new stack.

Apparently I'm wrong. Activities defined in different applications can share an affinity.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions