【问题标题】:onHandler(Intent intent) method of IntentService gets called multiple timesIntentService 的 onHandler(Intent intent) 方法被多次调用
【发布时间】:2014-02-26 00:24:18
【问题描述】:

我们正在从 SQLite db 加载大量数据,并使用 IntentService。

加载完成时,有一个活动从 IntentService 接收广播。在 IntentService 完成之前尝试启动 Activity 时,onHandler(Intent intent) 方法会被多次调用。

Intent Service 在应用程序启动时启动。

 public void onCreate(){
    super.onCreate();
    startService(new Intent(this, QuoteService.class);  
 }

意图服务

@Override
protected void onHandleIntent(Intent intent) {
    Log.v("Intent","Handler Intent");
    DataAccessObject dof=new DataAccessObject(getApplicationContext());
    ........
`........` *// data loaded from Data Access Object*

sendPersonListBroadcast();

    *//  method which sends Broadcast to Activity*

【问题讨论】:

  • 由于内存限制,Android 是否可能正在杀死和恢复您的服务?
  • 服务中的 onStartCommand(...) 是否被调用?服务中的 onStartCommand 或 onCreate 是否也被多次调用?

标签: android


【解决方案1】:

您的申请中是否还有一个流程?它会在你的应用程序的每个进程中调用onCreate

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-05
    相关资源
    最近更新 更多