I know that this Question is repeated but I can\'t find the answer in Internet.
I want to call a method from another class.
I\'ve Class1 and Class2.
In Class1:
Class2 inst = new Class2();
inst.UpdateEmployee();
And, if you don't want to instantiate Class2, declare UpdateEmployee as static and call it like this:
Class2.UpdateEmployee();
However, you'll normally want to do what @parag said.
Add this in MainActivity.
Intent intent = new Intent(getApplicationContext(), Heightimage.class);
startActivity(intent);
You should use the following code :
Class2 cls2 = new Class2();
cls2.UpdateEmployee();
In case you don't want to create a new instance to call the method, you can decalre the method as static
and then you can just call Class2.UpdateEmployee()
.