When to call activity context OR application context?

getApplicationContext() is almost always wrong. Ms. Hackborn (among others) have been very explicit that you only use getApplicationContext() when you know why you are using getApplicationContext() and only when you need to use getApplicationContext(). To be blunt, “some programmers” use getApplicationContext() (or getBaseContext(), to a lesser extent) because their Java experience is limited. They implement … Read more

What is the meaning of “this” in Java?

this refers to the current object. Each non-static method runs in the context of an object. So if you have a class like this: public class MyThisTest { private int a; public MyThisTest() { this(42); // calls the other constructor } public MyThisTest(int a) { this.a = a; // assigns the value of the parameter … Read more

How does the “this” keyword work?

this is a keyword in JavaScript that is a property of an execution context. Its main use is in functions and constructors. The rules for this are quite simple (if you stick to best practices). Technical description of this in the specification The ECMAScript standard defines this via the abstract operation (abbreviated AO) ResolveThisBinding: The … Read more