Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在后台做一些事情,但是一旦应用程序打开,我就需要这项服务
虽然,即使手机处于睡眠模式,我也需要在后台进行操作??
我尝试提供服务,但在手机进入睡眠模式后这项服务仍然存在,但我附加的内容不起作用。
使用这个
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlarmService_Service.html
我看到这个 链接,但我不明白!
为什么不能使用
Intent intent = new Intent(MyActivity.this, Myservice.class); startService(intent);
如果您在 Activity 的 onCreate 方法中执行此操作,那么它将在您的 Activity 运行后立即启动该服务。从那里,它应该在后台运行。你有什么问题?