I am programming a chat program for android.
I have the contact list as one activity and the chat windows as a second activity. I use startActivity to switch to the chat activity, but the chat activity gets reloaded every time. Therefore the screen gets cleared.
Is there a way to switch to a running activity without having to restart it?
private Intent myIntent = null;
…
if (myIntent == null)
myIntent = new Intent(HanasuAndroidActivity.activity, ChatWindow.class);
this.startActivity(myIntent);
Add FLAG_ACTIVITY_REORDER_TO_FRONT
to your Intent
. That will bring the existing activity instance to the foreground if it exists or create a new one if it does not exist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With