由网友(忆 倾城)分享简介:在我的应用程序,我有一个活动的,我想启动一个服务任何机构可以帮助我吗?In my app i have an activity from which i want to start an Service Can any body help me?推荐答案应用程序可以使用的上下文的.startService方法。该...
在我的应用程序,我有一个活动的,我想启动一个服务任何机构可以帮助我吗?
In my app i have an activity from which i want to start an Service Can any body help me?
推荐答案
应用程序可以使用的上下文的.startService方法。该方法将调用如果尚未创建服务的服务的onCreate方法;否则OnStart方法将被调用。这里是code:
The application can start the service with the help of the Context.startService method. The method will call the onCreate method of the service if service is not already created; else onStart method will be called. Here is the code:
Intent serviceIntent = new Intent();
serviceIntent.setAction("com.testApp.service.MY_SERVICE");
startService(serviceIntent);
相关推荐
最新文章