Why is my android activity being stopped? -
i have inherited code application need modify (yuck). activity in question implements surfaceholder.callback , sensoreventlistener. activity custom camera.
the code works fine autofocus, , take picture. once picture taken, start activity result crop image. activity started, surfaceholder.callback surfacedestroyed called (as expected). @ point existing application releases camera (as expected). however, when new crop activity launched, original camera activity stopped (stack trace: instrumentation.callactivityonstop->activity.performstop).
edit: complete stack trace when onstop of activity called:
cameraactivity.onstop() line: 784 instrumentation.callactivityonstop(activity) line: 1219 cameraactivity(activity).performstop() line: 5186 activitythread.performstopactivityinner(activitythread$activityclientrecord, activitythread$stopinfo, boolean, boolean) line: 3003 activitythread.handlestopactivity(ibinder, boolean, int) line: 3052 activitythread.access$1000(activitythread, ibinder, boolean, int) line: 139 activitythread$h.handlemessage(message) line: 1251 activitythread$h(handler).dispatchmessage(message) line: 99 looper.loop() line: 137 activitythread.main(string[]) line: 4918 method.invokenative(object, object[], class, class[], class, int, boolean) line: not available [native method] method.invoke(object, object...) line: 511 zygoteinit$methodandargscaller.run() line: 1004 zygoteinit.main(string[]) line: 771 nativestart.main(string[]) line: not available [native method]
because of camera activity no longer active, , doesn't receive result crop activity.
why destroying surface/releasing camera cause camera activity stop? must missing here...
make sure request code passed startactivityforresult positive or activity not result. weird part of api has bitten me before:
to quote docs: https://developer.android.com/reference/android/app/activity.html#startactivityforresult
requestcode if >= 0, code returned in onactivityresult() when activity exits.
in general, onstop can called time activity not foreground activity. not prevent receiving activity results. activity can restarted in order receive result.
http://developer.android.com/guide/components/activities.html
also, pay attention task affinity , stack , make sure crop activity running part of same task keep activity being stopped, again no assurances.
http://developer.android.com/guide/components/tasks-and-back-stack.html
Comments
Post a Comment