Java Code Examples for com.eveningoutpost.dexdrip.UtilityModels.ForegroundServiceStarter#start()

The following examples show how to use com.eveningoutpost.dexdrip.UtilityModels.ForegroundServiceStarter#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: G5CollectionService.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    if(key.compareTo("run_service_in_foreground") == 0) {
        Log.d("FOREGROUND", "run_service_in_foreground changed!");
        if (prefs.getBoolean("run_service_in_foreground", false)) {
            foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
            foregroundServiceStarter.start();
            Log.i(TAG, "Moving to foreground");
        } else {
            service.stopForeground(true);
            Log.i(TAG, "Removing from foreground");
        }
    }

    if(key.compareTo("run_ble_scan_constantly") == 0 || key.compareTo("always_unbond_G5") == 0
            || key.compareTo("always_get_new_keys") == 0 || key.compareTo("run_G5_ble_tasks_on_uithread") == 0) {
        Log.i(TAG, "G5 Setting Change");
        cycleScan(0);
    }


}
 
Example 2
Source File: WifiCollectionService.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    if (key.compareTo("run_service_in_foreground") == 0) {
        Log.d("FOREGROUND", "run_service_in_foreground changed!");
        if (prefs.getBoolean("run_service_in_foreground", false)) {
            foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), dexCollectionService);
            foregroundServiceStarter.start();
            Log.d(TAG, "Moving to foreground");
        } else {
            dexCollectionService.stopForeground(true);
            Log.d(TAG, "Removing from foreground");
        }
    }
}
 
Example 3
Source File: DoNothingService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
    UserError.Log.i(TAG, "onCreate: STARTING SERVICE");
}
 
Example 4
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {

    if (scanMeister == null) {
        scanMeister = new ScanMeister()
                .applyKnownWorkarounds()
                .addCallBack(this, TAG);
    }

    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    //mContext = getApplicationContext();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
    //bgToSpeech = BgToSpeech.setupTTS(mContext); //keep reference to not being garbage collected
    if (CollectionServiceStarter.isDexBridgeOrWifiandDexBridge()) {
        Log.i(TAG, "onCreate: resetting bridge_battery preference to 0");
        prefs.edit().putInt("bridge_battery", 0).apply();
        //if (Home.get_master()) GcmActivity.sendBridgeBattery(prefs.getInt("bridge_battery",-1));
    }

    cloner.dontClone(
            android.bluetooth.BluetoothDevice.class,
            android.bluetooth.BluetoothGattService.class
    );

    final IntentFilter pairingRequestFilter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
    pairingRequestFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1);
    registerReceiver(mPairingRequestRecevier, pairingRequestFilter);
    Log.i(TAG, "onCreate: STARTING SERVICE: pin code: " + DEFAULT_BT_PIN);

    Blukon.unBondIfBlukonAtInit();

}
 
Example 5
Source File: DexShareCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    if(key.compareTo("run_service_in_foreground") == 0) {
        Log.d("FOREGROUND", "run_service_in_foreground changed!");
        if (prefs.getBoolean("run_service_in_foreground", false)) {
            foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
            foregroundServiceStarter.start();
            Log.i(TAG, "Moving to foreground");
        } else {
            service.stopForeground(true);
            Log.i(TAG, "Removing from foreground");
        }
    }
}
 
Example 6
Source File: WifiCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    if (key.compareTo("run_service_in_foreground") == 0) {
        Log.d("FOREGROUND", "run_service_in_foreground changed!");
        if (prefs.getBoolean("run_service_in_foreground", false)) {
            foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), dexCollectionService);
            foregroundServiceStarter.start();
            Log.d(TAG, "Moving to foreground");
        } else {
            dexCollectionService.stopForeground(true);
            Log.d(TAG, "Removing from foreground");
        }
    }
}
 
Example 7
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {

    if (scanMeister == null) {
        scanMeister = new ScanMeister()
                .applyKnownWorkarounds()
                .addCallBack(this, TAG);
    }

    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    //mContext = getApplicationContext();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
    //bgToSpeech = BgToSpeech.setupTTS(mContext); //keep reference to not being garbage collected
    if (CollectionServiceStarter.isDexBridgeOrWifiandDexBridge()) {
        Log.i(TAG, "onCreate: resetting bridge_battery preference to 0");
        prefs.edit().putInt("bridge_battery", 0).apply();
        //if (Home.get_master()) GcmActivity.sendBridgeBattery(prefs.getInt("bridge_battery",-1));
    }

    cloner.dontClone(
            android.bluetooth.BluetoothDevice.class,
            android.bluetooth.BluetoothGattService.class
    );

    final IntentFilter pairingRequestFilter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
    pairingRequestFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1);
    registerReceiver(mPairingRequestRecevier, pairingRequestFilter);
    Log.i(TAG, "onCreate: STARTING SERVICE: pin code: " + DEFAULT_BT_PIN);

    Blukon.unBondIfBlukonAtInit();

}
 
Example 8
Source File: WifiCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    //mContext = getApplicationContext();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
    // bgToSpeech = BgToSpeech.setupTTS(mContext); //keep reference to not being garbage collected
    Log.i(TAG, "onCreate: STARTING SERVICE");
    lastState = "Starting up " + JoH.hourMinuteString();
}
 
Example 9
Source File: WifiCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    if (key.compareTo("run_service_in_foreground") == 0) {
        Log.d("FOREGROUND", "run_service_in_foreground changed!");
        if (prefs.getBoolean("run_service_in_foreground", false)) {
            foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), dexCollectionService);
            foregroundServiceStarter.start();
            Log.d(TAG, "Moving to foreground");
        } else {
            dexCollectionService.stopForeground(true);
            Log.d(TAG, "Removing from foreground");
        }
    }
}
 
Example 10
Source File: DoNothingService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
    UserError.Log.i(TAG, "onCreate: STARTING SERVICE");
}
 
Example 11
Source File: DoNothingService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    if (key.compareTo("run_service_in_foreground") == 0) {
        UserError.Log.d("FOREGROUND", "run_service_in_foreground changed!");
        if (prefs.getBoolean("run_service_in_foreground", false)) {
            foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), dexCollectionService);
            foregroundServiceStarter.start();
            UserError.Log.d(TAG, "Moving to foreground");
        } else {
            dexCollectionService.stopForeground(true);
            UserError.Log.d(TAG, "Removing from foreground");
        }
    }
}
 
Example 12
Source File: DexCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {

    if (scanMeister == null) {
        scanMeister = new ScanMeister()
                .applyKnownWorkarounds()
                .addCallBack(this, TAG);
    }

    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    //mContext = getApplicationContext();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
    //bgToSpeech = BgToSpeech.setupTTS(mContext); //keep reference to not being garbage collected
    if (CollectionServiceStarter.isDexBridgeOrWifiandDexBridge()) {
        Log.i(TAG, "onCreate: resetting bridge_battery preference to 0");
        prefs.edit().putInt("bridge_battery", 0).apply();
        //if (Home.get_master()) GcmActivity.sendBridgeBattery(prefs.getInt("bridge_battery",-1));
    }

    cloner.dontClone(
            android.bluetooth.BluetoothDevice.class,
            android.bluetooth.BluetoothGattService.class
    );

    final IntentFilter pairingRequestFilter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
    pairingRequestFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1);
    registerReceiver(mPairingRequestRecevier, pairingRequestFilter);
    Log.i(TAG, "onCreate: STARTING SERVICE: pin code: " + DEFAULT_BT_PIN);

    Blukon.unBondIfBlukonAtInit();

}
 
Example 13
Source File: DexCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    mContext = getApplicationContext();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
}
 
Example 14
Source File: DexCollectionService.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this);
    foregroundServiceStarter.start();
    mContext = getApplicationContext();
    dexCollectionService = this;
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    listenForChangeInSettings();
    bgToSpeech = BgToSpeech.setupTTS(mContext); //keep reference to not being garbage collected
    if(CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())){
        Log.i(TAG,"onCreate: resetting bridge_battery preference to 0");
        prefs.edit().putInt("bridge_battery",0).apply();
    }
    Log.i(TAG, "onCreate: STARTING SERVICE");
}
 
Example 15
Source File: DexShareCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    if(key.compareTo("run_service_in_foreground") == 0) {
        Log.e("FOREGROUND", "run_service_in_foreground changed!");
        if (prefs.getBoolean("run_service_in_foreground", false)) {
            foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
            foregroundServiceStarter.start();
            Log.w(TAG, "Moving to foreground");
        } else {
            service.stopForeground(true);
            Log.w(TAG, "Removing from foreground");
        }
    }
}
 
Example 16
Source File: G5BaseService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
protected void startInForeground() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
    foregroundServiceStarter.start();
    foregroundStatus();
}
 
Example 17
Source File: G5BaseService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
protected void startInForeground() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
    foregroundServiceStarter.start();
    foregroundStatus();
}
 
Example 18
Source File: JamBaseBluetoothService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
protected void startInForeground() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
    foregroundServiceStarter.start();
    foregroundStatus();
}
 
Example 19
Source File: JamBaseBluetoothService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
protected void startInForeground() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
    foregroundServiceStarter.start();
    foregroundStatus();
}
 
Example 20
Source File: G5BaseService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
protected void startInForeground() {
    foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
    foregroundServiceStarter.start();
    foregroundStatus();
}