The question seems quite stupid, but I spent quite a lot of time trying to solve it successfully. The problem is that Eclipse IDE throws me a various number of different errors if I try any solutions that I used in normal Java. Another thing is that just after implementing an interface I receive an error, and Eclipse change my class to abstract. So the source code is:
public class analyzer extends Activity { TextView dateAndTimeLabel; private Button closeButton; private int signalDBm = 0;
public class GetParams extends PhoneStateListener
{
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength)
{
super.onSignalStrengthsChanged(signalStrength);
signalDBm = signalStrength.getGsmSignalStrength();
}
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
TextView tv = (TextView)findViewById(R.id.text);
tv.setText("Greetings, My Lord");
EditText fld=(EditText)findViewById(R.id.field);
fld.setText("Nothing here at the moment");
new GetParams();
Button btn=(Button)findViewById(R.id.start);
btn.setOnClickListener(this);
btn=(Button)findViewById(R.id.stop);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
/**updateLabel();*/
/**Zakritie programmi*/
this.closeButton = (Button)this.findViewById(R.id.end);
this.closeButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
finish();
}
});
/**Prosmotr loga*/
Button btn_log=(Button)findViewById(R.id.viewlog);
btn_log.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
TextView tv = (TextView)findViewById(R.id.text);
tv.setText("U pressed the button, now you will die!");
EditText fld=(EditText)findViewById(R.id.field);
fld.setText("Power: " + signalDBm +" dBm\n" + "BER:... \n" + "Coordinates: ... \n");
};
});
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.start:
Toast.makeText(this, "GSM signal strength is " + signalDBm, Toast.LENGTH_SHORT).show();
break;
}
}
};
So there is a class GetParams with its method signalStrength.getGsmSignalStrength() that I want to use. One more thing I can add is that SignalStrength() class does not have a public constructor and this is the only way i can get to the method getGsmSignalStrength(). I would be very glad, if someone could help me because all my work stopped until I find a solution.