android - How to prevent multiple instances of an activity when it is launched with different intents -
i've come across bug in application when launched using "open" button on android market. seems launching market uses different intent launching phone's applications menu. leading multiple copies of same activity being launched, conflicting each other.
for example, if app consists of activities a-b-c above issue can lead stack a-b-c-a.
i tried using android:launchmode="singletask" on activities fix problem, has unwanted side-effect of clearing activity stack root whenever hit home.
example: a-b-c -> home -> when need a-b-c -> home -> a-b-c
is there way prevent launching multiple activities of same type without reseting root activity when using home?
add oncreate , should go:
// possible work around market launches. see https://issuetracker.google.com/issues/36907463 // more details. essentially, market launches main activity on top of other activities. // never want happen. instead, check if root , if not, finish. if (!istaskroot()) { final intent intent = getintent(); if (intent.hascategory(intent.category_launcher) && intent.action_main.equals(intent.getaction())) { log.w(log_tag, "main activity not root. finishing main activity instead of launching."); finish(); return; } }
Comments
Post a Comment