тот же IP-запрос достиг того же ngx worker_process?

Попробуйте это. меня устраивает. Здесь MonitoringService - мой класс обслуживания. У меня есть два действия, которые указывают на остановку или запуск службы. Я посылаю это значение из моего широковещательного приемника в зависимости от AIRPLANE_MODE_CHANGED.

@Override
public void onReceive(Context context, Intent intent) {   
    String action = intent.getAction();

    if(Intent.ACTION_AIRPLANE_MODE_CHANGED.equalsIgnoreCase(action)){
         boolean isOn = intent.getBooleanExtra("state", false);
         String serviceAction = isOn? MonitoringService.StopAction : MonitoringService.StartAction;
         Intent serviceIntent = new Intent(context, MonitoringService.class);
         serviceIntent.setAction(serviceAction);
         context.startService(serviceIntent);
    }
}

ПРИМЕЧАНИЕ. Я добавляю следующий код для запуска моего широковещательного приемника с именем: ManageLocationListenerReceiver.

<receiver
     android:name=".ManageLocationListenerReceiver"
     android:enabled="true"
     android:exported="true">
     <intent-filter>
         <action android:name="android.intent.action.AIRPLANE_MODE" />
     </intent-filter>
</receiver>
0
задан kevinyang 4 March 2019 в 02:12
поделиться