In android, how can I create a constructor
for a class
which is also an Activity
?
My problem is,
I want to have two activity classes (estimateFare and Mapping) which both send data to a an activity class (CalculateFare
). Mapping takes the data from real time network info, whereas estimateFare takes data from user input. I want CalculateFare
to be able to use the data from either class to perform the calculation, although I have run into trouble with the onCreate
method and the constructor for CalculateFare
. When the class is called during runtime of the application I get the following message in the LogCat
;
Unable to instantiate activity ComponentInfo.
A snippet from CalculateFare is as follows;
public class CalculateFare extends Activity {
TextView t;
static long length;
static int dist;
static int mMonth;
static int mDay;
public static double fare;
double rate1 = 0, rate2a, rate2b, rate3, rate4a, rate4b;
int remDist = 0;
double remLength;
private static int TTS_DATA_CHECK = 1;
private TextToSpeech tts = null;
private boolean ttsIsInit = false;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fare);
}
public CalculateFare(long length, int dist, int mMonth, int mDay)
{
}
public static void setLength(long l)
{
length = l;
}
public static void setDist(int d)
{
dist = d;
}
public static void setDate(int m, int d)
{
mMonth = m;
mDay = d;
}
public void calc()
{
Any Advice much appreciated