How to run a background process in service method completely?

前端 未结 1 1944
春和景丽
春和景丽 2021-01-25 14:01

Hi can any body show me how to run this code in service without activity, i have done this code in an activity but i dont want it to be an application i need it to be in a serv

1条回答
  •  执念已碎
    2021-01-25 14:39

    1.extends service class instead of Activity class and
    2. put your code into oncreate()
    3.add your service into manefest.
    4.call service from activity once like

             Intent service = new Intent(context, localService.class);
             context.startService(service); 
    

    follow this tutorial.

    0 讨论(0)
提交回复
热议问题