We have already seen that each time we create a new Android project we also create a new Java package, as a kind of container for the code we will write.
We have also learned about and played around with classes. We have imported and taken direct advantage of classes from the Android API such as Log
and Toast
. We have also used the AppCompatActivity
class, but in a different manner to that of Log
and Toast
. You might remember the first line of code in all our projects so far, after the import
statements, used the extends
keyword:
public class MyActivity extends AppCompatActivity {
When we extend a class as opposed to just importing it, we are kind of making it our own. In fact, if you take another look at the line of code you can see that we are making a new class, with a new name, MyActivity
, but basing it on the AppCompatActivity
class from the Android API.