Here is the code snippet,
class1.java
public class1 extends ListActivity {
public class1(){}
public testMethod()
{
Toast.makeText(getApplicationContext(),"Inside Method",Toast.LENGTH_SHORT).show();
}
}
class2.java
public class2 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
class1 c = new class1();
c.testMethod();
}
}
I want to call "testMethod" from class2, Currently it is giving following error,
08-04 22:59:27.428: ERROR/AndroidRuntime(1224): FATAL EXCEPTION: main
08-04 22:59:27.428: ERROR/AndroidRuntime(1224): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.assistant/com.assistant.AssistantActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.assistant/com.assistant.addNew}: java.lang.NullPointerException
Thanks.
I have two tabs,
Tab1 extends Activity (class2.java) => Contains form to add entry in DB
Tab2 extends ListActivity (class1.java) => Contains list of the added entries
I want to refresh the Tab2 whenever any entry is added through Tab1 and I have added method in class2.java to fill the list with updated DB entries.
Now, I want to call that method from class1.java after the entry is added.