지금은 Google 검색을 해봤지만 문서를 읽지 만 답변을 찾을 수 없습니다. 내 [단순화] 시나리오 :EventBus 게시 또는 게시 AbstractThreadedSyncAdapter에서 Activity로 Stitchy
사용자가 먼저 앱에 로그인하면 동기화 요청이 실행되고 내 onPerformSync가 호출됩니다. AbstractThreadedSyncAdapter에서 EventBus를 통해 MainActivity에 이벤트를 게시하려고합니다. 동기화가 끝나면 을으로 보내야 만 MainActivity가 호출되어 모든 작업이 완료되지만 작동하지 않습니다. 내 코드 :
onPerformSync
//Constructor
public MyMoneySyncAdapter(Context context, boolean autoInitialize) {
super(context, autoInitialize);
this.context = context;
EventBus.getDefault().post(new SyncEvent(SyncEvent.SyncStatus.Started));
}
AbstractThreadedSyncAdapter :
EventBus.getDefault().postSticky(new SyncEvent(SyncEvent.SyncStatus.Running));
//...some ops....
//all done
EventBus.getDefault().postSticky(new SyncEvent(SyncEvent.SyncStatus.Finished));
그리고 MainActivity :
@Override
protected void onResume() {
super.onResume();
EventBus.getDefault().register(this);
EventBus.getDefault().getStickyEvent(SyncEvent.class);
}
public void onEventMainThread(SyncEvent event){
//never gets called
}
이 가능 짝수는 syncService에서 이벤트를 게시하려면? 그렇지 않은 경우,이 문제점에 가장 적합한 솔루션은 무엇입니까?
감사합니다.