protected
?what i understand about Access-specifiers is as below::
Activity class
are defined protected
protected
Private access specifier allows a class to hide its member variables and member functions from other functions and objects. Only functions of the same class can access its private members. Even an instance of a class cannot access its private members.
stop() − An empty method which can be overridden, here you can write the logic to stop the application. init() − An empty method which can be overridden, but you cannot create a stage or scene in this method.
Access specifiers define how the members (attributes and methods) of a class can be accessed. In the example above, the members are public - which means that they can be accessed and modified from outside the code. However, what if we want members to be private and hidden from the outside world?
onStop(): Called when the activity is no longer visible to the user, because another activity has been resumed and is covering this one.
protected
for encapsulation within the framework package android.app and subclasses.android.app.ActivityManager
(same package) only. Depending on the method implementation, things could get messed up, if one can call those methods arbitrarily, from anywhere.So, this is by design and that design helps to avoid certain conceptual errors.
If you really must have a public
method, just implement one and use it from outside and within the corresponding lifecycle method.
However, though not recommended in this case, one could override protected
methods with public
methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With