我IntentService
在课堂上有这个。意图服务未启动。我究竟做错了什么?
public class getListOfUsersService extends IntentService {
public getListOfUsersService() {
super("DownloadListOfUsersIntentService");
System.out.println("intentService started");
}
@Override
protected void onHandleIntent(Intent intent) {
System.out.println("intentService onHandle started");
mService.sendMessage(Protocols.REQUEST_SEND_USER_LIST);
while(true) {
UserHolder UH = new UserHolder();
String usersdata = mService.getString();
System.out.println("userdata: "+ usersdata);
String array[] = usersdata.split("<!!>");
UH.setUserName(array[1]);
UH.setUserPhoneNum(array[2]);
userHolderList.add(UH);
System.out.println("added to usersList");
if(isDone) break;
}
}
}
我从一个方法开始:
public void update() {
System.out.println("update");
Intent intent = new Intent(this, getListOfUsersService.class);
startService(intent);
}
我在 Manifest 中注册了它:
<service
android:name=".getListOfUsersService"
android:exported="false"/>