-1

I am having three classes namely MainActivity,Timer_Service which extends service and LockedActivity which has an Activity. Now I want to use an intent like this

   Intent intent = new Intent(MainActivity.this, Timer_Service.class);
   startActivity(intent);

I expect it to work, but it's not working.

Dhyan V
  • 621
  • 1
  • 8
  • 18
ismail
  • 167
  • 1
  • 8

1 Answers1

2

if "Timer_Service" is activity then your below code work fine.

Intent intent = new Intent(MainActivity.this, Timer_Service.class);
startActivity(intent);

but currently "Timer_Service" is service then try below code:-

Intent intent = new Intent(MainActivity.this, Timer_Service.class);
startService(intent);
Dhaval Patel
  • 369
  • 1
  • 8