A
anu
Hi,
I am pretty new to java and am working on writing some android
scripts. However, since the basic problem I have is about the java
programming, I thought I should post it here.
I have a class called ServiceState that is public class but does not
have a constructor (when I try to use the default constructor in
Eclipse, the error is given that the constructor is not visible). This
same class also has some fields that are protected. In order to access
these fields, I created a new class that inherits the ServiceState
class. The protected fields are visible in this class. However, I keep
getting the message that the default constructor is not visible for
the superclass (i.e. ServiceState) and that a constructor needs to be
invoked explicitly. But, I am not quite sure how to do this. I tried
the following:
public class ServiceStateProt extends ServiceState {
public ServiceState(){
Intent in = new Intent("SERVICE_STATE_CHANGED_ACTION");
Handler target = new Handler();
Context ctx = null;
PhoneStateIntentReceiver psir = new
PhoneStateIntentReceiver(ctx,target);
psir.onReceiveIntent(ctx, in);
psir.registerIntent();
psir.notifyServiceState(22);
ServiceState ss = psir.getServiceState();
}
}
Since, getting the intent, then getting the servicestate from the
object of PhoneStateIntentReceiver is how you can get an instance of
the ServiceState class. But, all eclipse asks for is a return type for
the ServiceState method. What am I doing wrong? Please help!
Thanks a lot,
Anu
I am pretty new to java and am working on writing some android
scripts. However, since the basic problem I have is about the java
programming, I thought I should post it here.
I have a class called ServiceState that is public class but does not
have a constructor (when I try to use the default constructor in
Eclipse, the error is given that the constructor is not visible). This
same class also has some fields that are protected. In order to access
these fields, I created a new class that inherits the ServiceState
class. The protected fields are visible in this class. However, I keep
getting the message that the default constructor is not visible for
the superclass (i.e. ServiceState) and that a constructor needs to be
invoked explicitly. But, I am not quite sure how to do this. I tried
the following:
public class ServiceStateProt extends ServiceState {
public ServiceState(){
Intent in = new Intent("SERVICE_STATE_CHANGED_ACTION");
Handler target = new Handler();
Context ctx = null;
PhoneStateIntentReceiver psir = new
PhoneStateIntentReceiver(ctx,target);
psir.onReceiveIntent(ctx, in);
psir.registerIntent();
psir.notifyServiceState(22);
ServiceState ss = psir.getServiceState();
}
}
Since, getting the intent, then getting the servicestate from the
object of PhoneStateIntentReceiver is how you can get an instance of
the ServiceState class. But, all eclipse asks for is a return type for
the ServiceState method. What am I doing wrong? Please help!
Thanks a lot,
Anu