You definitely have to guarantee that any AudioTrack instances are done playing (stopped) AND released BEFORE you call finish(). Otherwise you will get Null exceptions on your app closing, just as you found.
So basically if you have another thread you have to put some kind of flag that waits for the AudioTrack to actually clear and release before your app exits. -niko On Sep 9, 11:33 am, OldSkoolMark <[email protected]> wrote: > I did a little more homework: > > http://stackoverflow.com/questions/3483182/activity-finish-method-wai...http://stackoverflow.com/questions/2590947/about-finish-in-android > > This makes me feel better about calling finish() and then > startActivity(). I may take the refactoring advice, > but in the meantime, I've isolated the problem to a thread that uses > AudioTrack to play short samples. I've arranged for it not to be > running > when the UI is being reset and all is good. > > On Sep 8, 1:09 pm, Mark Murphy <[email protected]> wrote: > > > > > On Wed, Sep 8, 2010 at 3:44 PM, OldSkoolMark <[email protected]> wrote: > > > Alternative design approaches would also be greatly appreciated. > > > Step #1: Refactor such that your UI initialization is not in > > onCreate(), but is in some other private method (referred to here as > > setupViews()). > > > Step #2: In onResume(), on a change in layout, call setupViews(). > > > Step #3: There is no step #3. > > > In other words, why destroy and recreate the activity just to load in > > a different layout? Heck, developers grumble constantly about Android > > doing that by default for orientation changes... > > > -- > > Mark Murphy (a Commons > > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > > Android Training in London:http://skillsmatter.com/go/os-mobile-server -- 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

