I want to call a method of an abstract class in my own class. The abstract class is:
public abstract class Call {
public Connection getEarliestConnectio
Firstly, Call
an abstract class, therefore you cannot instantiate it directly. You must create a subclass, say MyCall extends Call
which overrides any abstract methods in Call.
Getting a NullPointerException
means that whatever you are passing in as an argument to getCallFailedString()
hasn't been initialized. So after you create your subclass of Call, you'd have to instantiate it and then pass this in to your method, so something like:
class MyCall extends Call
{
//override any abstract methods here...
}
Wherever you are calling getCallFailedString()
would then require something above it like:
Call cal = new MyCall();
Activity activity = new MyActivity();
activity.getCallFailedString(cal);
Make sure your object "cal" is initialized and not null. Also, you won't be able to instantiate a Call object(as its an abstarct class). Instead, declare class Call as an interface and implement its method getEarliestConnection(), in your class.
Looks like the Call cal
is null before it is passed into the function getCallFailedString
. Make sure you extend Call
and instantiate the extended class and pass it into getCallFailedString
.