Exemplo n.º 1
0
  @Override
  public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    if (mContext == null) {
      mContext = LoaderService.this;
    }
    if (mRunnable == null) {
      mRunnable =
          new Runnable() {

            @Override
            public void run() {
              // TODO Auto-generated method stub
              if (!Constant.isTaskRunning) {
                mHandler.sendEmptyMessage(3);
                mHandler.postDelayed(mRunnable, 3600000);
              }
            }
          };
    }

    SharedPreferences preferences = getSharedPreferences("testmode", Context.MODE_PRIVATE);
    testmode = preferences.getString("tag", "false");
    preferences = null;
    preferences = getSharedPreferences("address", Context.MODE_PRIVATE);
    serverAddress = preferences.getString("contentpath", "");

    Intent noKillMe = new Intent("com.smartcenter.HOME_DONT_KILL_ME");
    noKillMe.putExtra("packageName", "com.changhong.downloadermanager");
    sendBroadcast(noKillMe);

    if (startByBroadcast && !Constant.isTaskRunning) {
      Log.i(TAG, "startBybroadcast!!!");
      mHandler.postDelayed(mRunnable, 10000);
      startByBroadcast = false;
    }
  }