创建 IntentService

要创建一个 IntentService,请创建一个扩展 IntentService 的类,并在其中包含一个覆盖 onHandleIntent 的方法:

package com.example.myapp;
public class MyIntentService extends IntentService {
    @Override
     protected void onHandleIntent (Intent workIntent) {
         //Do something in the background, based on the contents of workIntent.
     }
}