\'m developing an Android Application in which I have
I\'ve two classes class A and Class B .
In class A , I tried the code Snippets like below,
If you need to call the same method from both Activities why not then use a third object?
public class FirstActivity extends Activity
{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
}
// Utility.method() used somewhere in FirstActivity
}
public class Utility {
public static void method()
{
}
}
public class SecondActivity extends Activity
{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
Utility.method();
}
}
Of course making it static depends on the use case.