@Override
 protected String doInBackground(Void... params) {
   while (!isCancelled()) {
     // 如果没有取消
     if (ComConnectivityManager.getInstance().isConnected()) {
       String device_token = UmengRegistrar.getRegistrationId(mContext);
       if (!TextUtils.isEmpty(device_token)) {
         DebugUtils.logD(TAG, "CheckDeviceTokenTask doInBackground() get " + device_token);
         return device_token;
       }
       SystemClock.sleep(5000); // sleep 5 s
     } else {
       SystemClock.sleep(60000); // sleep 60 s
     }
   }
   return null;
 }
Example #2
0
  @Override
  public void initData() {
    mPushAgent = PushAgent.getInstance(context);
    //        if (!mPushAgent.isEnabled()) {
    mPushAgent.enable(mRegisterCallback);
    //        }

    String device_token = UmengRegistrar.getRegistrationId(context);
    showLogD("device_token " + device_token);
    Log.i("TAG", "device_token " + device_token);
    SPUtils.saveSPData("token", device_token);
    mLocationClient = ((MyApplication) getApplication()).mLocationClient;

    //        register(device_token);
    copyDB(DBNAME);
    copyDB(SCHOOL);
    copyDB(TEACHER_TYPE);
    initLocation();
    mLocationClient.start();
    setListener();
  }