start method in a fragment from a different class

Am trying to execute a method onclicklistener from a different class in a fragment. Am having this error. I am new to programming, would anyone be kind enough to help me filter this problem.

This is the method on BottomSheetMotoristFragment.java

bRequest.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

MainActivity mainAct = new MainActivity();

if (!Common.isDriverFound)

mainAct.requestPickUpHere(FirebaseAuth.getInstance().getCurrentUser().getUid());

else

Common.sendRequestToDriver(Common.driverId,mFcmService,mainAct.getBaseContext(),Common.mLastLocation);

}

});

This is the method i would like to call from MainActivity.java

public void requestPickUpHere(String uid) {

DatabaseReference dbRequest = FirebaseDatabase.getInstance().getReference(Common.pickup_request_tbl);

GeoFire mGeoFire = new GeoFire(dbRequest);

mGeoFire.setLocation(uid,new GeoLocation(Common.mLastLocation.getLatitude(),Common.mLastLocation.getLongitude()));

if (mUserMarker.isVisible())

mUserMarker.remove();

//Add new marker

mUserMarker = mMap.addMarker(new MarkerOptions()

.title("Pickup Here")

.snippet("")

.position(new LatLng(Common.mLastLocation.getLatitude(),Common.mLastLocation.getLongitude()))

.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

mUserMarker.showInfoWindow();

bRequest.setText("Getting your driver......");

findDriver();

}...

Read More »

By: StackOverFlow - Sunday, 17 June

Related Posts