ActivityNotFoundException while trying to start a service.

孤街浪徒 提交于 2019-12-02 02:19:48

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!