Question

I am new to android development and have a confusion that if an activity( a class extends Activity) has some public methods, can we access these public methods outside that activity.

Regards, Waneya Iqbal

Was it helpful?

Solution

Yes. public methods are... public. This means that they're accessible from anywhere.

Read http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

OTHER TIPS

Yes, you may. Activities are just like any other classes in Java.

Yet, you should be careful where and when do you call them, since they might not be exist or not in correct state at a specific time.

Not sure of what you want to achieve, but yes you can pass a reference of the activity to the caller, just as you would with any object, and call its public methods.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top