void move() {
   MyServiceManager.setServiceUnavailable();
   if (MyServiceManager.getServiceState() == MyServiceState.STOPPED) {
     new MoveDataBetweenStoragesTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
   } else {
     MyServiceManager.stopService();
     Toast.makeText(
             parentActivity.getActivity(),
             mContext.getText(R.string.system_is_busy_try_later),
             Toast.LENGTH_LONG)
         .show();
   }
 }
Пример #2
0
 void move() {
   MyServiceManager.setServiceUnavailable();
   if (MyServiceManager.getServiceState() == MyServiceState.STOPPED) {
     AsyncTaskLauncher.execute(this, true, new MoveDataBetweenStoragesTask());
   } else {
     MyServiceManager.stopService();
     Toast.makeText(
             parentFragment.getActivity(),
             mContext.getText(R.string.system_is_busy_try_later),
             Toast.LENGTH_LONG)
         .show();
   }
 }
Пример #3
0
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (action.equals(MyAction.SERVICE_STATE.getAction())) {
     MyContextHolder.initialize(context, this);
     synchronized (mServiceState) {
       stateQueuedTime = System.nanoTime();
       waitingForServiceState = false;
       mServiceState = MyServiceState.load(intent.getStringExtra(IntentExtra.SERVICE_STATE.key));
     }
     MyLog.d(this, "Notification received: Service state=" + mServiceState);
   } else if ("android.intent.action.BOOT_COMPLETED".equals(action)) {
     MyLog.d(this, "Trying to start service on boot");
     sendCommand(CommandData.getEmpty());
   } else if ("android.intent.action.ACTION_SHUTDOWN".equals(action)) {
     // We need this to persist unsaved data in the service
     MyLog.d(this, "Stopping service on Shutdown");
     setServiceUnavailable();
     stopService();
   }
 }