Use a class constructor in Android

504 views Asked by At

I need to instantiate a class in the MainActivity class .Therefore i used the constructor defined on the class but the problem it includes some parameters that i dont know how to instantiate with.

this is the class constructor:(please see the comments)

public class FallbackLocationTracker  implements LocationTracker, LocationTracker.LocationUpdateListener {


private boolean isRunning;

private ProviderLocationTracker gps;
private ProviderLocationTracker net;

private LocationUpdateListener listener;

Location lastLoc;
long lastTime;

public FallbackLocationTracker(Context context, ProviderLocationTracker.ProviderType type) {
    gps = new ProviderLocationTracker(context, ProviderLocationTracker.ProviderType.GPS);
    net = new ProviderLocationTracker(context, ProviderLocationTracker.ProviderType.NETWORK);
}

And this is what i have done in the Mainactivity :

public class MainActivity extends Activity {

GPSTracker gps;



@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    gps = new FallbackLocationTracker( );//What should i do here to make use of the class and all the methods ??

}
1

There are 1 answers

3
ligi On BEST ANSWER
new FallbackLocationTracker(this,ProviderLocationTracker.ProviderType.NETWORK);