I have a common menu on my app with icons. Clicking an icon will start an Activity. Is there a way to know if an activity is already running and prevent it from starting multiple times (or from multiple entries)? Also can I bring an activity that is in onPause state to the front?
Use this:
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
while starting Activity
.
from documentation:
If set in an Intent passed to Context.startActivity(), this flag will cause the launched activity to be brought to the front of its task's history stack if it is already running.
In your activity declaration in Manifest file, add the tag android:launchMode="singleInstance"
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