I am using service in my program where i have MainActivity.java and MyService.java in Mainactivity i called intent as
public void onClick(View src)
{
switch (src.getId()) {
case R.id.ButtonStart:
Log.d(TAG, "onClick: starting service");
startService(new Intent(this,com.example.MyService1.class));
break;
case R.id.ButtonStop:
Log.d(TAG,"onClick: stopping service");
stopService(new Intent(this,com.example.MyService1.class));
break;
}
}
but i am getting error on Log.d that “WARN/ActivityManager(68): Unable to start service Intent { cmp=com.example/.MyService1 }: not found” please tell me solution.
You are using file
MyService.javaand starting service like this:Now insure that why you are using
com.example.MyService1.classinstead ofMyServicehere?Just simply use like this:
startService(new Intent(this,MyService.class));