Here is my Activity class
public class A extends Activity
{
.......
.......
//here i have to call my test() method of B activity
new B.test();
}
This is my next Activity
public class B extends Activity
{
......
public void test(){
//some code }
}
But the test() method is not not executing. I put a Toast message in test() method. but it is not showing the Toast message. How to call that test() method. Where am I wrong? Do i have to override onCreate() in B activity? Please tell me. Thanks in advance.
You can write test method in separate class which doesn’t extends Activity.So that you can call the method from two activities whenever you need.
An activity is a different screen and you can call it by intent,so that it can be shown on screen