I am getting an Activity not found exception while trying to start a service. I have the service registered in the Manifest. Adding what I think is the relevant code and the Log
your method startDrive
is wrong
private void startDrive()
{
Log.w("rakshak", "Start drive clicked");
Intent intent = new Intent(getActivity(), GPSService.class);
intent.setAction(util.START_DRIVE);
getActivity().startActivity(intent);
}
you are using startActivity
instead of startService
. Also stopDrive()
is starting the service again
GPSService
is a service. It is not an Activity. You cant do as
getActivity().startActivity(intent);
instead of do startService(intent);
For more information refer Docs