0

i already read the question Activity restart on rotation Android . But it does not really help me.

I've two activities. The Second gets updated from an Async_Task, which holds a few Threads which i cannot just restart. The Problem i got is, that rotating my Device forces an Activity-restart, which means i loose my Reference to the Async_Task. Is there any possibility to pass Objektreferences from one activity to another?

Thanks for help!

Community
  • 1
  • 1
hammer
  • 3
  • 1

1 Answers1

0

Make your reference static, or see: http://developer.android.com/guide/topics/resources/runtime-changes.html#RetainingAnObject

Miguel Morales
  • 1,707
  • 10
  • 10
  • Thanks! I think the Link will do it! But how can i pass an object with running threads with a static reference? Maybe i don't get it, but does not matter at the moment:) – hammer May 17 '11 at 22:48
  • I prefer the static method. So, on your Activity class do static MyActivity ACTIVE_INSTANCE; Then onCreate() do ACTIVE_INSTANCE = this and onDestroy do ACTIVE_INSTANCE = null. Then after your async task has finished do ACTIVE_INSTANCE.someMethod(). That should work across activity restarts. – Miguel Morales May 17 '11 at 22:57