我在我的活动中创建了一个处理程序。处理程序将存储在应用程序对象中。
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.action_activity);
    appData = (AttachApplication) getApplication();
    Handler updateHandler = new Handler() {
        public void handlerMessage(Message msg) {
            Log.d( TAG, "handle message " );
        }
    };
    appData.setUpdateHandler( updateHandler );
}
我的计划是当我在我的服务中 setEmtpyMessage 时将调用这个 handleMessage。该服务从应用程序对象中检索处理程序。
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d(TAG, "onStartCommand of attachService");
    List<Job> jobList = DBManager.getInstance().getAllOpenJobs();
    appData = (AttachApplication) getApplication();
    updateHandler = appData.getUpdateHandler();
            updateHandler.sendEmptyMessage( 101 );
我检查了日志,但没有句柄消息,因此我的计划似乎不起作用。每次我的服务完成工作时,我都想更新一个文本字段。