There is also an other way to get the current context. I don't know if it is the same as version 3 that you described:
4. new Intent(MyActivityClass.this, MyOtherActivity.class); It works for me. But be careful when using this inside threads. I had some problems to get the context of my application when executing code outside the main thread. For this cases I use the android.os.Handler class to enqueue the execution in the main thread. Am 11.08.2009 um 04:18 schrieb Teal: > > Hi, > > Are there any differences between the following code? > > 1. new Intent(this, MyOtherActivity.class); > 2. new Intent(Context.this, MyOtherActivity.class); > 3. new Intent(getApplicationContext(), MyOtherActivity.class); > > I think 1 vs 2 will matter when I'm inside an Activity or inside an > anonymous inner class (such as writing a button's onClickListener()). > But is there a difference between 2 and 3? Recommendation of one vs > the other? Thank you. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" 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-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

