IntentService 不能和UI交互,如果想将结果呈现在UI上,必须将结果发给Activity,让其帮忙显示
其次IntentService 只能顺序的处理Request,如果上一个Request没有处理完,则发送一个Request的时候必须等待.
IntentService 中的操作不能被中断.
一般通过实现IntentService的子类来新建一个IntentService,
public class RSSPullService extends IntentService {
@Override
protected void onHandleIntent(Intent workIntent) {
// Gets data from the incoming Intent
String dataString = workIntent.getDataString();
...
// Do work here, based on the contents of dataString
...
}
}
所有的service 必须在manifest文件中声明
<application
android:icon="@drawable/icon"
android:label="@string/app_name">
...
<!--
Because android:exported is set to "false",
the service is only available to this app.
-->
<service
android:name=".RSSPullService"
android:exported="false"/>
...
<application/>
其次IntentService 只能顺序的处理Request,如果上一个Request没有处理完,则发送一个Request的时候必须等待.
IntentService 中的操作不能被中断.
一般通过实现IntentService的子类来新建一个IntentService,
public class RSSPullService extends IntentService {
@Override
protected void onHandleIntent(Intent workIntent) {
// Gets data from the incoming Intent
String dataString = workIntent.getDataString();
...
// Do work here, based on the contents of dataString
...
}
}
所有的service 必须在manifest文件中声明
<application
android:icon="@drawable/icon"
android:label="@string/app_name">
...
<!--
Because android:exported is set to "false",
the service is only available to this app.
-->
<service
android:name=".RSSPullService"
android:exported="false"/>
...
<application/>