[android-developers] getCurrentActivity()

2012-03-12 Thread bob
Why is there no static function like Activity.getCurrentActivity()?

Right now, I am saving the Activity in a static variable in onCreate
so I can access it easily later on.  I suspect there must be a better
way.

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


Re: [android-developers] getCurrentActivity()

2012-03-12 Thread Mark Murphy
On Mon, Mar 12, 2012 at 2:39 PM, bob b...@coolfone.comze.com wrote:
 Why is there no static function like Activity.getCurrentActivity()?

Because the current activity (which I presume you are defining as
the activity in the foreground) may not be in your app.

 Right now, I am saving the Activity in a static variable in onCreate
 so I can access it easily later on.  I suspect there must be a better
 way.

Delete all that code, to get rid of your memory leak you introduced.
Then, solve whatever problem you think you are solving some other way.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 4.1 Available!

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


Re: [android-developers] getCurrentActivity()

2012-03-12 Thread Carlos Silva
this on a class that extends Activity isn't simple enough?

On Mon, Mar 12, 2012 at 17:39, bob b...@coolfone.comze.com wrote:

 Why is there no static function like Activity.getCurrentActivity()?

 Right now, I am saving the Activity in a static variable in onCreate
 so I can access it easily later on.  I suspect there must be a better
 way.

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


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