I am trying to show the user information on Incoming Call screen, whenever there is an Incoming Call. So i have a Broadcast Receiver listening to Incoming calls, which starts the Intent Service, which subsequently starts an Activity (with Theme Dialog) .
Now Whenever there is an Incoming Call , My Activity Dialog Pops Up and Shows as Intended.
Problem : When the Activity Dialog is already on the Screen and Incoming call comes, there is no new Activity Dialog with new Information. I guess that whenever there is an Instance , android does not creates the new one. So it seems like my problem is "Creating Multiple Instances of an Activity".
Please note that i am starting an Activity from an Intent Service using FLAG_NEW_TASK.
If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.
If you need to receive the new intents on this activity when the clear_top flag is set, override the onNewIntent() method.
Sahil Rally wrote:@Deepak
Although i can receive the new Intent via overriding the onNewIntent() method, how would i end up having multiple instances of an activity dialog.
When an activity is launched, the android framework creates a stacked history of activities. This is used to allow the user to press the back button and go back to a previous activity. If you do not want this behavior use the FLAG_ACTIVITY_CLEAR_TOP option.
Using FLAG_NEW_TASK will make your activity the first on the history stack. I'm not sure that is what you want.
I want stack of same activity instances . Let us name an Activity as "A".
I want my broadcast receiver to launch new activity instance A whenever there is an incoming call .
So iff there are 5 calls on my phone, i can see 5 activities i.e. Stack : A A A A A
Android documentation says that it is default behaviour but it is not actually happening.
and i am using FLAG_NEW_TASK because am starting activity from an Intent service and it is required , dont exactly know why, but without it ereor comes.