Again, get the stack crawls.  This discussion is fairly pointless without at
least having the stack crawls of the app when it ANRed.

As for calling finish() in onStop() -- you can call finish() at any time.
 (Well, not after onDestroy().)  And in fact it would be hard for doing this
in onStop() to directly cause an ANR, since by this time the activity that
is executing onStop() no longer has input focus so *can't* ANR because of
something happening then.

mKeyWaiter.waitForNextEventTarget not returning...  well, yeah, that is what
happens when there is an ANR.  The window manager has dispatched an event,
is waiting for the application to process it, and ends up waiting for more
than 5 seconds.  ANR.  That's what that function is doing.

On Sat, Jul 31, 2010 at 7:30 PM, James Wang <[email protected]> wrote:

> @TreKing
> Thanks for your replies. We do have some reasons to call finish
> because Android did not finish one when another is shown before it.
> >Probably, but with your code, not Android.
> Document does not say finish is not allowed to be called at onStop.
> How to explain there is no problem with calling finish just after
> startActivity.
>
> @Dianne
> Thanks for your replies. We do believe it is a problem with framework.
> WindowManagerService.java:
>
>    private int dispatchPointer(QueuedEvent qev, MotionEvent ev, int
> pid, int uid) {
>        if (DEBUG_INPUT || WindowManagerPolicy.WATCH_POINTER)
> Log.v(TAG,
>                "dispatchPointer " + ev);
>
>        if (MEASURE_LATENCY) {
>            lt.sample("3 Wait for last dispatch ", System.nanoTime() -
> qev.whenNano);
>        }
>
>        Object targetObj = mKeyWaiter.waitForNextEventTarget(null,
> qev,
>                ev, true, false, pid, uid);
>
> When calling finish() after startActivity,
> mKeyWaiter.waitForNextEventTarge returns activity A. And after
> checking A.isVisibleLW(), the key up event is discarded successfully.
>
> When calling finish() at onStop, ANR happens in
> mKeyWaiter.waitForNextEventTarge and it is seems never get out.
>
> James
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to