To register and login, use your Google, Twitter, Facebook, LinkedIn, or OpenID credentials.

This is allowing us to stop most spam registrations. We've deleted most of the spam accounts that got through, and we're closely watching for more.

onDestroy() restart multiple instance distortion Android

choonschoons Posts: 52
edited February 2013 in Pd Everywhere

Hi guys, I noticed today that my app called onDestroy() and restarted with that familiar distortion that happens when multiple instances of Pd are running. My setup is uses the PdService approach from the book so I was kind of surprised it happened. I believe what actually happened was that multiple instances of my patch were started as the app went through its init routine that happens at start up.

How can I prevent that? I'd rather just have the app completely shut down when that happens. That leads me to another question- what's the best way to manually shut down a libPd app? I know people often argue against doing that with Android apps, but I disagree since battery drain is so high with apps like this.

Looking around I found this guide again
About halfway down is a cleanup routine. Is that still the preferred way to handle shutdown?


  • NitroooNitrooo Posts: 21
    edited February 2013

    You maybe better post your code, but... I personally release the pd instance in the onPause() method if I can, as it's the only method guaranteed to be called before the app's destruction by the os (

    Of course if your app is really intended to run a background service while the main activity is paused, well, then that's not a path you can walk and the release of the resources may require a different approach.

  • choonschoons Posts: 52

    @Nitrooo thanks for the response and sorry for not getting back sooner, but yeah I use the background service approach so I decided to work on other things and come back to this later

    I finally got around to really debugging this behavior and discovered the cause is related to having my app set to run in landscape orientation only. When the phone goes to sleep or screen is turned off it fires the typical onDestroy/onCreate() cycle that happens when manually changing phone orientation. Strangely, even though I listen for onConfigurationChanged() it was never showing as fired. I added android:configChanges="orientation" to the manifest file and now it goes to onPause() and remains there the way it should instead of cycling immediately to onDestroy()/onCreate().

Sign In or Register to comment.